Skip to content

Start extracted Datadog propagation tags from the extracted priority - #13010

Draft
dougqh wants to merge 3 commits into
dougqh/segment-propagationfrom
dougqh/extract-priority-in-ptags
Draft

dougqh wants to merge 3 commits into
dougqh/segment-propagationfrom
dougqh/extract-priority-in-ptags

Conversation

@dougqh

@dougqh dougqh commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

The Datadog extractor now keeps the raw x-datadog-tags value and parses it when the context is built. At that point the sampling priority is known, so the extracted PropagationTags starts from the priority the trace will inherit.

Before, the tags were parsed as soon as the header was seen, which isn't necessarily after x-datadog-sampling-priority. They started at UNSET, and the root span's constructor then installed the priority as a second sampling-state snapshot (setSamplingPriority(priority, UNKNOWN)). That install is now a no-op.

With APM tracing disabled, the upstream priority may not be inherited, so the tags still start at UNSET and behave exactly as before.

Motivation

TraceSegment work (APMLP-2049), step 2: one sampling state per extracted trace.

I counted SamplingState constructions with a temporary counter while running PropagationScenariosBenchmark's two upstream header sets through extract, root start, inject and finish. Per extracted trace, the count goes from 4 to 3:

  • extract: 3 → 3
  • root start: 1 → 0

The remaining extra two are the throwaway W3C PropagationTags from compound extraction and the compound merge's new state. Removing them is the next step.

Allocation (PropagationScenariosBenchmark, JDK 17, @Threads(8), 1 fork × 5 iterations, -prof gc; base = #13009):

scenario sampler upstream base B/op this PR B/op Δ
leaf default sameVersion 2241.3 ± 5.4 2216.3 ± 9.8 −25.0
leaf default withOtelMember 2512.3 ± 29.1 2462.5 ± 2.7 −49.8
leaf rule sameVersion 2240.0 ± 6.5 2206.2 ± 8.1 −33.8
leaf rule withOtelMember 2373.4 ± 16.0 2325.7 ± 23.6 −47.6
intermediate default sameVersion 3848.5 ± 5.6 3809.2 ± 7.5 −39.3
intermediate default withOtelMember 4048.0 ± 8.3 3999.1 ± 9.5 −48.9
intermediate rule sameVersion 3868.7 ± 5.2 3809.9 ± 19.2 −58.8
intermediate rule withOtelMember 4075.3 ± 42.4 3963.0 ± 9.1 −112.3

Throughput is pending. The host was busy during these runs, and all pairs overlap within their error. A quiet run will be added before this is marked ready.

Additional Notes

Output is unchanged. Starting from the priority at extract leads to the same final state as installing it at root start:

Tests:

  • DatadogHttpExtractorTest: the extracted tags carry the priority whichever header comes first, and don't when APM tracing is disabled.
  • DDSpanContextPropagationTagsTest: the root span keeps the extracted SamplingState instance.

The full dd-trace-core suite passes, apart from the 2 TracerConnectionReliabilityTest cases, which need Docker.

Stacked: master ← #13008 ← #13000 ← #13009 ← this PR.

🤖 Generated with Claude Code

@dougqh dougqh added comp: core Tracer core tag: performance Performance related changes 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-datadog-prod-us1

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

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 81.25%
• Overall Coverage: 59.86% (-0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 67e1349 | 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.04 s 13.97 s [-0.4%; +1.4%] (no difference)
startup:insecure-bank:tracing:Agent 12.94 s 12.97 s [-0.9%; +0.5%] (no difference)
startup:petclinic:appsec:Agent 17.16 s 16.99 s [+0.0%; +1.9%] (maybe worse)
startup:petclinic:iast:Agent 16.98 s 17.02 s [-1.0%; +0.5%] (no difference)
startup:petclinic:profiling:Agent 16.69 s 16.73 s [-1.3%; +0.8%] (no difference)
startup:petclinic:sca:Agent 17.05 s 17.03 s [-0.6%; +0.9%] (no difference)
startup:petclinic:tracing:Agent 15.71 s 16.15 s [-7.0%; +1.5%] (no difference)

Commit: 67e1349d · 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 3 commits October 23, 2026 16:13
The Datadog extractor parsed x-datadog-tags as soon as it saw the
header, before the sampling priority was necessarily known, so the
tags started at UNSET and the root span's constructor installed the
priority as a second sampling state. The raw header is now kept and
parsed when the context is built, starting from the priority the trace
will inherit, so the root span's reconcile is a no-op.

When APM tracing is disabled, the upstream priority may not be
inherited, so the tags still start at UNSET there.

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>

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 tag: performance Performance related changes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant