Skip to content

Hold trace propagation tags and origin on the trace segment - #13009

Draft
dougqh wants to merge 4 commits into
dougqh/lazy-child-ptagsfrom
dougqh/segment-propagation
Draft

dougqh wants to merge 4 commits into
dougqh/lazy-child-ptagsfrom
dougqh/segment-propagation

Conversation

@dougqh

@dougqh dougqh commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Moves the trace's PropagationTags and origin off the local root's DDSpanContext and onto the TraceCollector (the trace segment, #13008). Sampling-priority reads and writes, force-keep, origin, and getPropagationTags() now go straight to the collector instead of looking up the root span first. That includes the root's own construction, which used to depend on falling back to the span itself before it registered.

A span still holds its own PropagationTags only when a write targets a non-root span (_dd.p.ts / _dd.p.debug). That behavior is unchanged from #13000.

Motivation

Part of the TraceSegment work (APMLP-2049): trace-level propagation state gets a trace-level home. This also sets up a single per-trace sampling state built at extract.

Shallow sizes (JOL ClassLayout.instanceSize(), JDK 17, compressed oops):

class master #13008 this PR
DDSpanContext (per span) 152 B 136 B 128 B
PendingTrace (per trace) 96 B 120 B 128 B
StreamingTraceCollector (per trace) 40 B 64 B 72 B

Against master, the stack's shallow cost per trace is 32 − 24·N bytes for N spans. That is on top of #13000's ~200 B saving per child span.

Additional Notes

  • Stacked: master ← Make the trace collector the trace segment and request context #13008 ← Stop allocating propagation tags for local child spans #13000 ← this PR.
  • Set-once PropagationTags: the root's constructor hands its PropagationTags to the collector with a set-once CAS. If a context is constructed directly with tags while its trace already has some (only tests do this), those tags become that span's own.
  • Test changes:
    • DDSpanTest's origin test reflected on the removed private field; it now checks that the trace shares one origin.
    • PayloadDispatcherImplTest builds spans on a Mockito-mocked PendingTrace, so its mock now calls the real trace-state accessors.
  • Tests (JDK 17, local):
    • dd-trace-core: 4824 tests, 3 failures. Two are TracerConnectionReliabilityTest, which needs Docker. The third, PendingTraceBufferTest.testingTracerFlareDumpWithMultipleTraces, passes when run on its own and looks order-dependent.
    • dd-trace-ot, CI Visibility and AppSec all pass.

🤖 Generated with Claude Code

@dougqh dougqh added comp: core Tracer core tag: no release notes Changes to exclude from release notes type: refactoring comp: context propagation Trace context propagation tag: ai generated Largely based on code generated by an AI or LLM labels Oct 23, 2026
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 94.74%
• Overall Coverage: 59.41% (-0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 93e891c | Docs | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.06 s 13.95 s [+0.0%; +1.5%] (maybe worse)
startup:insecure-bank:tracing:Agent 12.90 s 13.04 s [-1.8%; -0.3%] (maybe better)
startup:petclinic:appsec:Agent 17.09 s 17.04 s [-0.5%; +1.1%] (no difference)
startup:petclinic:iast:Agent 17.06 s 17.08 s [-1.0%; +0.7%] (no difference)
startup:petclinic:profiling:Agent 16.67 s 16.64 s [-0.8%; +1.0%] (no difference)
startup:petclinic:sca:Agent 16.61 s 17.01 s [-6.6%; +1.9%] (no difference)
startup:petclinic:tracing:Agent 16.12 s 16.19 s [-1.4%; +0.4%] (no difference)

Commit: 93e891cd · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

dougqh and others added 4 commits November 11, 2026 20:01
The trace's PropagationTags and origin now live on the TraceCollector
instead of the local root's DDSpanContext. Sampling, force-keep,
origin, and propagation-tag reads go straight to the collector rather
than resolving the root span first, including during the root's own
construction.

A span keeps its own PropagationTags only when a write targets a
non-root span (_dd.p.ts / _dd.p.debug), as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh
dougqh force-pushed the dougqh/segment-propagation branch from 372fb6b to 93e891c Compare November 12, 2026 01:53
@dougqh
dougqh force-pushed the dougqh/lazy-child-ptags branch from 35909f3 to 64288d9 Compare November 12, 2026 01:53

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: context propagation Trace context propagation comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant