Skip to content

Honour request header tags mapped onto headers - #12695

Open
ValentinZakharov wants to merge 1 commit into
masterfrom
vzakharov/honour-header-tags-on-consumed-headers
Open

ValentinZakharov wants to merge 1 commit into
masterfrom
vzakharov/honour-header-tags-on-consumed-headers

Conversation

@ValentinZakharov

Copy link
Copy Markdown
Contributor

What Does This Do

Makes a DD_TRACE_REQUEST_HEADER_TAGS mapping on a header that the tracer also consumes for another purpose actually produce its tag.

Every context interpreter recognises certain headers - User-Agent, the Forwarded / X-Forwarded-* family, and the client-IP headers (X-Real-IP, True-Client-IP, CF-Connecting-IP, the configurable DD_TRACE_CLIENT_IP_HEADER, …) - captures them via the handled* helpers, and then returns from accept() immediately. That early return means the header never reaches handleTags(), so a header tag mapped onto it is silently dropped.

This is the same class of bug that #12662 fixed for X-Amzn-Trace-Id, generalised to the remaining consumed headers. Instead of removing each early return one by one, this PR applies the header→tag / header→baggage mappings once up front in accept(), so no later early return can bypass them. The semantic capture of each header (IP, user-agent, forwarding, trace context) is unchanged.

The fix is applied to every interpreter that carries this pattern: DatadogHttpCodec, XRayHttpCodec, W3CHttpCodec, HaystackHttpCodec, B3HttpCodec (both multi and single) and NoneCodec. Each interpreter keeps its existing tag/baggage semantics; the mappings simply run before the switch rather than after it.

Motivation

APMS-20654

Additional Notes

Because the mappings now run before the switch, a mapping onto a header that was previously consumed and returned early - including the trace-context headers themselves - is now honoured, consistent with every other header. X-Amzn-Trace-Id is covered as a side effect, so this supersedes #12662 if merged first.

ConsumedHeaderTagMappingTest exercises every consumed header across all seven interpreters and asserts that the mapped tag is produced, the semantic capture is preserved, and the trace context is still extracted. All new tests were confirmed to fail without the codec changes.

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@ValentinZakharov ValentinZakharov self-assigned this Sep 29, 2026
@ValentinZakharov
ValentinZakharov requested a review from a team as a code owner September 29, 2026 21:16
@ValentinZakharov
ValentinZakharov removed the request for review from a team September 29, 2026 21:16
@ValentinZakharov ValentinZakharov added the comp: context propagation Trace context propagation label Sep 29, 2026

@datadog-prod-us1-4 datadog-prod-us1-4 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

Moving tag and baggage mapping ahead of consumed-header short circuits preserves existing precedence and semantic extraction while allowing configured mappings to take effect.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 483781b · @DataDog review to ask questions

@datadog-prod-us1-4

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Sep 29, 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.08 s 13.96 s [+0.1%; +1.6%] (maybe worse)
startup:insecure-bank:tracing:Agent 12.89 s 12.96 s [-1.3%; +0.1%] (no difference)
startup:petclinic:appsec:Agent 17.00 s 16.92 s [-0.5%; +1.4%] (no difference)
startup:petclinic:iast:Agent 16.91 s 17.03 s [-1.8%; +0.4%] (no difference)
startup:petclinic:profiling:Agent 16.25 s 16.72 s [-7.0%; +1.3%] (no difference)
startup:petclinic:sca:Agent 16.99 s 16.76 s [+0.6%; +2.1%] (maybe worse)
startup:petclinic:tracing:Agent 16.17 s 16.28 s [-1.7%; +0.4%] (no difference)

Commit: 483781b0 · 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.

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 type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants