Decouple W3C lastParentId from shared propagation-tag mutation#11702
Draft
dougqh wants to merge 1 commit into
Draft
Decouple W3C lastParentId from shared propagation-tag mutation#11702dougqh wants to merge 1 commit into
dougqh wants to merge 1 commit into
Conversation
Injecting a W3C tracestate wrote the injecting span's id into the (trace-level, shared via getRootSpanContextOrThis) PropagationTags via updateLastParentId, then read it back to build the `p:` member. Concurrent sibling injects race on that shared field -- A writes A, B writes B, A can emit B as its last-parent. Supply the injecting span's id as a parameter instead: PropagationTags.headerValue(HeaderType, lastParentIdOverride). W3CHttpCodec passes context.getSpanId(); the W3C codec uses the override for `p:`, falling back to the stored inbound last-parent-id for non-inject callers (span-link traceState). No inject-time mutation of the shared tags -> no race, no cross-talk between sibling injects, and the inbound last-parent-id is preserved for its ctor/extraction reads. updateLastParentId is now unused and removed (it was the only inject-time mutator; the inbound value is set at construction). OPM stamping is left as-is on purpose: it writes a process-constant local OPM, so concurrent injects are idempotent (no race). Full dd-trace-core propagation + span-build suite passes (1947 tests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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. |
Contributor
|
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
Stop mutating the (trace-level, shared)
PropagationTagswith the injecting span's id at W3C inject time; supply it as a parameter instead.Why
W3CHttpCodec.injectTraceStatedid:But
getPropagationTags()routes to the root (getRootSpanContextOrThis()), so the field is effectively shared across the segment. Concurrent sibling injects race on it — span A writes A, span B writes B, A reads back B and emits the wrongp:(W3C last-parent-id). It also thrashed the W3C header cache (invalidated on every differing id). Pre-existing; not introduced by the per-span sharing work (#11701).How
PropagationTags.headerValue(HeaderType, CharSequence lastParentIdOverride).W3CHttpCodecpassescontext.getSpanId();W3CPTagsCodecuses the override forp:, falling back to the stored inbound last-parent-id when there's no override (span-linktraceState, extraction reads).updateLastParentIdis now unused and removed (it was the only inject-time mutator; the inbound value is set at construction).Deliberately out of scope
OPM stamping is left as-is. It writes a process-constant local OPM, so concurrent injects are idempotent — no real race — and OPM is new; let it settle. Same-shape decouple is a clean future follow-up (or it rides the TraceSegment migration).
Test / validation
PropagationTagsLastParentIdTest— override suppliesp:; sibling injects don't cross-talk; inboundp:preserved and unmutated by override use.dd-trace-corepropagation + span-build suite green (1947 tests, 0 failures), incl.W3CHttpInjectorTest.updateLastParentIdOnChildSpan, the 611W3CPropagationTagscases, and span-linktraceState.Relationship
Step 2 of the PTags-per-segment work; pairs with #11701 (share parent's PTags for local children — the allocation win). Both are early steps toward a first-class
TraceSegment.🤖 Generated with Claude Code