feat(llmobs): read experiment scope from APM baggage in StartSpan#4651
Conversation
Child LLMObs spans now check for the _ml_obs.experiment_id baggage item on the APM span and automatically set scope to "experiments" when present.
Verifies that child spans created with StartSpan inherit scope "experiments" when parent sets _ml_obs.experiment_id baggage.
Codecov Report❌ Patch coverage is
Additional details and impacted files
🚀 New features to boost your workflow:
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: b30b279 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
BenchmarksBenchmark execution time: 2026-04-10 09:40:42 Comparing candidate commit b30b279 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 216 metrics, 8 unstable metrics.
|
What does this PR do?
Adds experiment scope propagation to
StartSpanvia APM baggage. When a parent span sets_ml_obs.experiment_idas a baggage item (e.g. viaStartExperimentSpan), child LLMObs spans created withStartSpannow automatically read that baggage and set their scope to"experiments".This requires exposing
BaggageItem(key string) stringon theAPMSpaninterface (the underlyingSpantype already has this method).Motivation
The Python SDK already does this — every span checks
span.context.get_baggage_item("_ml_obs.experiment_id")and sets_dd.scope = "experiments"if present. The Go SDK only set scope insideStartExperimentSpandirectly, meaning child spans created viaStartSpanwere missing the experiments scope even when the baggage was propagated on the APM span.Reviewer's Checklist
make lintlocally.make testlocally.make generatelocally.make fix-moduleslocally.