fix(llmobs): propagate llmobs_parent_id in _current_trace_context#18253
Open
jasonmp85 wants to merge 2 commits into
Open
fix(llmobs): propagate llmobs_parent_id in _current_trace_context#18253jasonmp85 wants to merge 2 commits into
jasonmp85 wants to merge 2 commits into
Conversation
Codeowners resolved as |
|
a30e33b to
733bf26
Compare
733bf26 to
460ab7a
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
emmettbutler
approved these changes
May 27, 2026
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.
Summary
_current_trace_context()setsPROPAGATED_LLMOBS_TRACE_ID_KEY(_dd.p.llmobs_trace_id) on the returned context but omitsPROPAGATED_PARENT_ID_KEY(_dd.p.llmobs_parent_id). Any consumer that readscontext._metadirectly — includingHTTPPropagator.injectand non-Python clients (Go, Java, etc.) receiving the propagated headers — will see the trace ID but not the parent span ID.This breaks distributed LLMObs tracing to non-Python services. For example, dd-trace-go's
contextWithPropagatedLLMSpanrequires both tags to be non-empty before it attaches the propagated LLMObs context:Without
_dd.p.llmobs_parent_id, a downstream Go service starts a new root LLMObs trace instead of inheriting the parent, breaking the distributed trace tree.Fix
One line in
_current_trace_context():PROPAGATED_PARENT_ID_KEYis already defined in_constants.pyand imported in_llmobs.py— it was just never set on this code path.Note:
_inject_llmobs_context(thehttp.span_injectpath, used byinject_distributed_headers) already sets this correctly. This fix brings_current_trace_contextto parity.Test
Added
test_current_trace_context_includes_parent_idtotests/llmobs/test_propagation.py. Asserts that the context returned by_current_trace_context()has bothPROPAGATED_PARENT_ID_KEYandPROPAGATED_LLMOBS_TRACE_ID_KEYset, withparent_id == str(span.span_id).