Skip to main content

Datadog LLM Observability `TraceSource` adapter for whatifd.

Project description

whatifd-datadog

Datadog LLM Observability TraceSource adapter for whatifd.

Reads previously-ingested LLM-Obs spans (read-only) and projects each trace into a whatifd RawTrace, so you can fork Datadog-traced agent turns, replay them under a proposed change, and gate a PR on the verdict.

Status

  • ✅ Span-iterator adapter (DatadogTraceSource) + conformance test (offline)
  • ✅ Thin Export-API client (DatadogExportClient, [live] extra)
  • ❌ Recorded-cassette smoke against a live Datadog org — deferred (needs a real org)

Install

pip install whatifd-datadog          # adapter core
pip install whatifd-datadog[live]    # + httpx for the Export API client

Why a thin httpx client (not the official SDK)

The official datadog-api-client Python SDK covers LLM Observability ingestion / experiments / eval-metric, but does not expose a spans-read path. The documented read surface is the LLM Observability Export API:

  • GET /api/v2/llm-obs/v1/spans/events
  • POST /api/v2/llm-obs/v1/spans/events/search

This package wraps it with a minimal httpx client. Auth requires both the API key and the Application key.

Usage

import os
from whatifd_datadog import DatadogTraceSource
from whatifd_datadog.client import DatadogExportClient, make_spans_provider

client = DatadogExportClient(
    api_key=os.environ["DD_API_KEY"],
    app_key=os.environ["DD_APP_KEY"],
    site=os.environ.get("DD_SITE", "datadoghq.com"),
)

source = DatadogTraceSource(
    # ALWAYS bound the window — the Export API defaults to the last 15 min.
    spans_provider=make_spans_provider(client, ml_app="my-agent", from_ts="now-24h"),
    cohort_classifier=lambda spans: (
        "failure" if any("whatifd:failure" in (s.get("tags") or []) for s in spans)
        else "baseline"
    ),
)

for raw in source.iter_traces():
    print(raw.trace_id, raw.cohort)

The adapter is span-iterator-shaped (like whatifd-phoenix): spans_provider is any zero-arg callable yielding normalized span dicts, so you can wire your own transport or feed fixtures in tests with no network.

Emitting verdict metrics (the sink)

After whatifd fork writes its report, push verdict + cohort metrics to Datadog so dashboards/monitors can track Ship-rate and regression trends:

whatifd-datadog-emit reports/whatifd-fork-2026-06-04.json --tag service:my-agent

Emits gauges: whatifd.verdict.code (0=ship / 1=dont_ship / 2=inconclusive, matching the CLI exit code), whatifd.cohort.{selected,replayed,scored, improved,regressed,unchanged,median_delta,ci_lower,ci_upper,floor_passed, regression_ratio,improvement_ratio} (tagged cohort:<name>; null-valued fields like an unavailable CI bound are skipped, not zeroed), and whatifd.findings.blocking.

  • Out of whatifd core by design — it reads the already-written report and only reports; it never touches the verdict path.
  • Soft-fails by default — a metrics hiccup exits 0 so it can't turn a green verdict red in CI. Pass --strict to fail the step on emission errors.
  • Agentless: POST /api/v1/series with DD_API_KEY (DD_SITE for region). --dry-run prints metrics without submitting. Needs the [live] extra.

Cardinal alignment

  • #5 Sensitive[T] at the boundary — span input / output (Datadog SearchedIO) are wrapped as Sensitive[str] at ingress, on root and child spans alike; PII-registered attribute keys are wrapped via wrap_pii_attributes.
  • #1 failure-as-datamake_spans_provider requires an explicit from_ts; the API's 15-minute default would otherwise silently return a near-empty cohort. Missing httpx raises a clear install hint.
  • #9 orchestration, not compute — streaming pagination; no CPU tricks.
  • #10 statistical claimscluster_key_support() returns an empty tuple; Datadog session_id / trace_id are not mined as cluster keys.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whatifd_datadog-0.3.0.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whatifd_datadog-0.3.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file whatifd_datadog-0.3.0.tar.gz.

File metadata

  • Download URL: whatifd_datadog-0.3.0.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for whatifd_datadog-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1cc82ca37412e292a51b35151e4ab1454e89bec7371f551c69d25fcc4c3e9851
MD5 d706a2ebf69df0b439853c0da6429ffc
BLAKE2b-256 07f32d85ea87ef0aa65f2db4521e0162c19601bea7e29f30283495917e808bd0

See more details on using hashes here.

Provenance

The following attestation bundles were made for whatifd_datadog-0.3.0.tar.gz:

Publisher: release.yml on victoralfred/whatifd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file whatifd_datadog-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for whatifd_datadog-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f01888794fef938d58d4049505596d1085ac4e3f55b101ce3c05c27631e36c8
MD5 7a7d61053d7488c355dcc3f22bc07810
BLAKE2b-256 6be89b4f4a7cec386788e8101b03de8b9837d6890fdac008fc698b7975caaff2

See more details on using hashes here.

Provenance

The following attestation bundles were made for whatifd_datadog-0.3.0-py3-none-any.whl:

Publisher: release.yml on victoralfred/whatifd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page