Skip to content

Conversation

@PROFeNoM
Copy link
Contributor

@PROFeNoM PROFeNoM commented Dec 23, 2025

What does this PR do?

Adds multi-tenant API key support for LLM Observability, enabling platforms like Dust.tt to route LLMObs telemetry to different Datadog organizations from a single process.

New API:

await llmobs.withRoutingContext({ ddApiKey: customerKey, ddSite: customerSite }, async () => {
  // All LLMObs spans created here will be routed to the customer's Datadog org
})

Flow:

User Code → withRoutingContext() → Span Created (routing tags captured) → 
Span Finished → SpanProcessor → Writer (routes to correct buffer/endpoint)

Key changes:

  • Added withRoutingContext(options, fn) method to LLMObs SDK using AsyncLocalStorage
  • Routing context is captured at span creation time and stored in span metadata
  • Modified BaseLLMObsWriter to use a multi-buffer architecture (one buffer per apiKey:site combination)
  • Each buffer flushes independently to its corresponding Datadog organization endpoint
  • Works in agentless mode only (per design decision)

Motivation

Multi-tenant AI platforms (like Dust.tt) need to send LLM Observability data to their customers' Datadog organizations rather than a single shared organization. This enables:

  • Customer-specific trace visibility in their own Datadog account
  • Data isolation between tenants
  • Compliance with data residency requirements (different DD sites per customer)

Plugin Checklist

Additional Notes

@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 65.33333% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.81%. Comparing base (a5fcf17) to head (059c462).

Files with missing lines Patch % Lines
packages/dd-trace/src/llmobs/writers/base.js 70.83% 14 Missing ⚠️
packages/dd-trace/src/llmobs/routing-context.js 44.44% 5 Missing ⚠️
packages/dd-trace/src/llmobs/tagger.js 42.85% 4 Missing ⚠️
packages/dd-trace/src/llmobs/sdk.js 33.33% 2 Missing ⚠️
packages/dd-trace/src/llmobs/noop.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7158      +/-   ##
==========================================
- Coverage   84.48%   83.81%   -0.68%     
==========================================
  Files         523      522       -1     
  Lines       22448    22413      -35     
==========================================
- Hits        18966    18786     -180     
- Misses       3482     3627     +145     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PROFeNoM
Copy link
Contributor Author

@codex review

@github-actions
Copy link

github-actions bot commented Dec 23, 2025

Overall package size

Self size: 4.4 MB
Deduped: 5.22 MB
No deduping: 5.22 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.0 | 68.46 kB | 797.03 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Dec 23, 2025

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

❄️ 1 New flaky test detected

cypress@14.5.4 esm test management quarantine fails if quarantine is not enabled from integration-tests/cypress/cypress.spec.js (Datadog) (Fix with Cursor)
Cannot read properties of undefined (reading 'content')

ℹ️ Info

🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 059c462 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@pr-commenter
Copy link

pr-commenter bot commented Dec 23, 2025

Benchmarks

Benchmark execution time: 2025-12-23 10:23:50

Comparing candidate commit 059c462 in PR branch alex/MLOB-4999_multi-tenant-routing-context-support with baseline commit a5fcf17 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 289 metrics, 31 unstable metrics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants