Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🟢 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>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
More details
The propagated-context fallback is consistent with manual-span inheritance, preserving same-trace context precedence and paired sampling decisions. The completed static review reported no actionable defects.
🤖 Bits Code Review · Commit b2333f7
| } | ||
|
|
||
| LLMObsPropagationValues propagated = span.spanContext().getExtractedLLMObsValues(); | ||
| if (propagated != null) { |
There was a problem hiding this comment.
There might sometimes be cases where the request headers have parent_id=undefined but ml_app/trace_id are provided. AFAIK In these cases this PR is currently treating this as a continuation of that trace, but we should not do that (i.e. create a new trace with a new root span if parent ID is undefined or missing). I'm pretty sure this is what dd-trace-py does as well. Can we fix this (and make sure the manually instrumented propagation also does the same)?
There was a problem hiding this comment.
Gotcha, this condition now checks that the parent ID is not undefined before continuing to extract the context from the headers.
…efined Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.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).End to End Testing
Two Java services, each in its own JVM. Neither calls an LLMObs distributed-tracing API:
planner-serviceopens aplanner-agentLLMObs span with a session and makes a plain JDKHttpClientPOST. Its LLMObs context goes out inx-datadog-tags(Propagate LLM Observability context across service boundaries #12416).openai-serviceis an embedded Jetty endpoint that answers withopenai-java. It opens no LLMObs span and has noDD_LLMOBS_ML_APP, so itsml_appdefaults to its ownDD_SERVICE, as a real second service's would. The only LLMObs span it produces is the integration's own.The same scenario runs on two agent builds:
179e8935d6, this PR's merge base:masterwith #12416, without this PRe9ef593613, this PRBefore
The OpenAI span is the root of its own LLMObs trace:
parent_id: undefined, reported under the downstream service'sml_app:openai-service, with no session and no agent attribution. The two services do share an LLMObs trace id: between two Java services the APM trace id is shared, and with nothing to inherit both sides seed the LLMObs id from it. Even so, the OpenAI span is a second, unconnected root, filed under another application.planner-agentspan (ml_app:planner-app, sessionpr12878-before-session-0)OpenAI.createChatCompletionspan (ml_app:openai-service, no session)After
The OpenAI span is a child of the caller's
planner-agentspan, in the caller'sml_appand session, withplanner-agentas its parent agent. Nothing is set locally.planner-agentspan, withOpenAI.createChatCompletionnested under it (parent_id: 8194838372146278380,ml_app:planner-app, sessionpr12878-after-session-0)Claude session:
0ad2d9f2-7e72-4f45-874f-bb9105d3daf9Resume:
claude --resume 0ad2d9f2-7e72-4f45-874f-bb9105d3daf9🤖 Generated with Claude Code