Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Follow-up to #12416. Auto-instrumented
openai.requestspans now pick up the LLM Observability context that arrived on the inbound request, so a service that calls OpenAI directly (an HTTP handler or queue consumer that never opens an LLMObs span of its own) stays in its caller's LLMObs trace instead of starting a new one.To get there without copying
DDLLMObsSpan's parent resolution a second time, both span types now share one resolver,LLMObsParent.Motivation
#12416 taught
DDLLMObsSpanto fall back to the extracted_dd.p.llmobs_*values, butOpenAiDecoratoronly read the in-processLLMObsContext.current(). That is null in the fully automatic path (inbound request → OpenAI call, no manual span), so the LLM span became an LLMObs root: new trace id,parent_id: undefined, no session, no agent attribution, and a locally rolled sampling decision that could disagree with the caller's.The resolution rules (same-trace check, in-process before propagated, rate and decision adopted together, roll only at a true root) were already ~100 lines in
DDLLMObsSpan. Every future LLM integration would need them too, so they now live in one place.Approach
LLMObsParent(new,internal-api)LLMObsParent.resolve(span)returns the parent a span inherits from, tried in order:LLMObsContext, only if it's on the same trace as the span.span.spanContext().getExtractedLLMObsValues(), with the trace id converted from its decimal wire form byLLMObsTraceId.fromWire.isRoot()is true, and only then does the caller roll a sampling decision.It only resolves; it writes nothing to the span. Caller-specific rules stay with the caller: explicit values winning (with
""treated as unset), the service-defaultml_app, an agent span naming itself as its descendants' parent agent, opening a context for children, and seeding the trace id at a root.Two details keep it behaviour-preserving:
DDLLMObsSpanre-attaches these values for its descendants, and the propagation source injects them one by one, so normalising them here would change the wire.A context that is active but on another trace is exposed as
ignoredContext, soDDLLMObsSpankeeps its existing error log. The OpenAI decorator still doesn't log.LLMObsSampler.decide(DDTraceId)replaces the identicalsample(...) ? "1" : "0"expression in both callers.Callers
DDLLMObsSpan: the resolution block becomes oneresolvecall plus the explicit-value layering. Everything after it is unchanged: trace-id seeding, theml_appdefault, the agent override, tag writes andLLMObsContext.attach.OpenAiDecorator: applies the resolved parent to its tags. This is where the OpenAI fix comes from: it now gets the propagated fallback for free. It still leavestrace_idunset at a root, and the mapper seeds it the same wayDDLLMObsSpandoes.LLMObsTraceIdmoved tointernal-apiThe resolver needs
fromWire, and instrumentation modules can't seeagent-llmobs. The class and its test move unchanged fromdatadog.trace.llmobs.domaintodatadog.trace.api.llmobs. The only other change is thatformatis nowpublic.Reviewing
Commits are meant to be read in order:
LLMObsTraceIdmove and forked tests.session_id/agent_versioncounts as unset.Testing
LLMObsParentTest(new, 11 cases): same-trace context wins over propagated values; in-process values pass through unpaired; empty reads as absent; stale context falls back to propagated, or to a root that reports what it ignored; propagated trace id converted from the wire; propagated context without a parent id or verdict is still not a root; each pairing rule.LlmObsContextPropagationForkedTest: 6 new cases extract realx-datadog-*headers under a server span before calling the OpenAI client:agent-llmobs(105 tests), OpenAI unit tests (95) and forked tests (20), andinternal-api'sdatadog.trace.api.llmobs(115).Not yet done: an end-to-end run across two processes against a real agent, including the Python ↔ Java scenarios from #12416. That is the check that catches trace-id format mismatches.
Claude session:
0ad2d9f2-7e72-4f45-874f-bb9105d3daf9Resume:
claude --resume 0ad2d9f2-7e72-4f45-874f-bb9105d3daf9🤖 Generated with Claude Code