Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ddtrace/llmobs/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,17 @@

PROXY_REQUEST = "llmobs.proxy_request"

# experiment span baggage keys to be propagated across boundaries
EXPERIMENT_ID_KEY = "_ml_obs.experiment_id"
EXPERIMENT_RUN_ID_KEY = "_ml_obs.experiment_run_id"
EXPERIMENT_RUN_ITERATION_KEY = "_ml_obs.experiment_run_iteration"
EXPERIMENT_PROJECT_NAME_KEY = "_ml_obs.experiment_project_name"
EXPERIMENT_PROJECT_ID_KEY = "_ml_obs.experiment_project_id"
EXPERIMENT_DATASET_NAME_KEY = "_ml_obs.experiment_dataset_name"
EXPERIMENT_NAME_KEY = "_ml_obs.experiment_name"

# experiment context keys
EXPERIMENT_RECORD_METADATA = "_ml_obs.meta.metadata"
EXPERIMENT_EXPECTED_OUTPUT = "_ml_obs.meta.input.expected_output"
EXPERIMENTS_INPUT = "_ml_obs.meta.input"
EXPERIMENTS_OUTPUT = "_ml_obs.meta.output"
Expand Down
7 changes: 6 additions & 1 deletion ddtrace/llmobs/_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from ddtrace.internal.logger import get_logger
from ddtrace.llmobs._constants import DD_SITES_NEEDING_APP_SUBDOMAIN
from ddtrace.llmobs._constants import EXPERIMENT_EXPECTED_OUTPUT
from ddtrace.llmobs._constants import EXPERIMENT_RECORD_METADATA
from ddtrace.llmobs._utils import convert_tags_dict_to_list
from ddtrace.llmobs._utils import safe_json
from ddtrace.version import __version__
Expand Down Expand Up @@ -488,7 +489,11 @@ def _process_record(self, idx_record: Tuple[int, DatasetRecord], run: _Experimen
except Exception:
span.set_exc_info(*sys.exc_info())
self._llmobs_instance.annotate(span, input_data=input_data, output_data=output_data, tags=tags)
span._set_ctx_item(EXPERIMENT_EXPECTED_OUTPUT, safe_json(record["expected_output"]))

span._set_ctx_item(EXPERIMENT_EXPECTED_OUTPUT, record["expected_output"])
if "metadata" in record:
span._set_ctx_item(EXPERIMENT_RECORD_METADATA, record["metadata"])

return {
"idx": idx,
"span_id": span_id,
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/llmobs/_llmobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,9 +1738,9 @@ def _tag_freeform_io(cls, span, input_value=None, output_value=None):
arbitrary structured or non structured IO values in its spans
"""
if input_value is not None:
span._set_ctx_item(EXPERIMENTS_INPUT, safe_json(input_value))
span._set_ctx_item(EXPERIMENTS_INPUT, input_value)
if output_value is not None:
span._set_ctx_item(EXPERIMENTS_OUTPUT, safe_json(output_value))
span._set_ctx_item(EXPERIMENTS_OUTPUT, output_value)

@staticmethod
def _set_dict_attribute(span: Span, key, value: Dict[str, Any]) -> None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
upgrade:
- |
LLM Observability: Experiments spans now contain metadata from the dataset record.
- |
LLM Observability: Experiments spans' input, output, expected_output fields are now emitted as is so that if data in
any of the columns are objects, they can be searchable in Datadog.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
interactions:
- request:
body: '{"data": {"type": "datasets", "id": "0969efc9-f104-45cc-b955-25b329e91293",
"attributes": {"insert_records": [{"input": {"prompt": "What is the capital
of France?"}, "expected_output": {"answer": "Paris"}, "metadata": {"difficulty":
"easy"}}], "update_records": [], "delete_records": []}}}'
headers:
Accept:
- '*/*'
? !!python/object/apply:multidict._multidict.istr
- Accept-Encoding
: - identity
Connection:
- keep-alive
Content-Length:
- '289'
? !!python/object/apply:multidict._multidict.istr
- Content-Type
: - application/json
User-Agent:
- python-requests/2.32.3
method: POST
uri: https://api.datadoghq.com/api/unstable/llm-obs/v1/datasets/0969efc9-f104-45cc-b955-25b329e91293/batch_update
response:
body:
string: '{"data":[]}'
headers:
content-length:
- '11'
content-security-policy:
- frame-ancestors 'self'; report-uri https://logs.browser-intake-datadoghq.com/api/v2/logs?dd-api-key=pube4f163c23bbf91c16b8f57f56af9fc58&dd-evp-origin=content-security-policy&ddsource=csp-report&ddtags=site%3Adatadoghq.com
content-type:
- application/vnd.api+json
date:
- Tue, 09 Dec 2025 03:28:32 GMT
strict-transport-security:
- max-age=31536000; includeSubDomains; preload
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
x-frame-options:
- SAMEORIGIN
status:
code: 200
message: OK
version: 1
Loading
Loading