Skip to content

Honour request header tags mapped onto X-Amzn-Trace-Id - #12662

Closed
RoseannaM wants to merge 3 commits into
masterfrom
roseanna.mcfarlane/honour-header-tag-on-x-amzn-trace-id
Closed

RoseannaM wants to merge 3 commits into
masterfrom
roseanna.mcfarlane/honour-header-tag-on-x-amzn-trace-id

Conversation

@RoseannaM

@RoseannaM RoseannaM commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Makes a DD_TRACE_REQUEST_HEADER_TAGS mapping on x-amzn-trace-id actually produce its tag.

Both the Datadog and the X-Ray context interpreters recognise X-Amzn-Trace-Id, extract AWS X-Ray context from it, and then return from accept() immediately. That early return means the header never reaches handleTags(), so a header tag mapped onto it is silently dropped. This PR removes the early return in both interpreters, leaving X-Ray extraction itself unchanged.

Motivation

APMS-20654

Additional Notes

Falling through to the shared tail of accept() also routes the header past handledIpHeaders() and the baggage mapping. x-amzn-trace-id cannot match an IP header, so the only behaviour change beyond the tag is that an explicit baggage mapping on the header is now honoured too — consistent with every other header.

Both regression tests were confirmed to fail without the codec changes.

Contributor Checklist

  • Title follows the contribution guidelines
  • type: and comp: labels assigned
  • Formatted with ./gradlew spotlessApply
  • Tests added
  • No new configuration flags, so no public documentation change needed

The Datadog and X-Ray context interpreters both consumed X-Amzn-Trace-Id
as AWS X-Ray context and returned from accept() immediately, so the
header never reached handleTags(). A DD_TRACE_REQUEST_HEADER_TAGS entry
mapping that header to a tag was therefore silently dropped whenever the
interpreter that consumed it produced the winning context.

Because CompoundExtractor keeps the tags of only the first extractor to
return a context, the mapping appeared to work intermittently: it was
honoured only when the Datadog interpreter returned no context at all
and the tracecontext interpreter's tags were used instead. Any request
that carried Datadog propagation headers, or merely a User-Agent, lost
the tag.

Drop the early return in both interpreters so the header is still passed
to handleTags() after the X-Ray context has been extracted from it.

Co-authored-by: Cursor <cursoragent@cursor.com>
@RoseannaM RoseannaM added comp: context propagation Trace context propagation tag: ai generated Largely based on code generated by an AI or LLM type: bug labels Sep 28, 2026
@datadog-prod-us1-5

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Sep 28, 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.03 s 13.99 s [-0.5%; +1.2%] (no difference)
startup:insecure-bank:tracing:Agent 12.96 s 13.03 s [-1.5%; +0.4%] (no difference)
startup:petclinic:appsec:Agent 17.06 s 16.98 s [-0.4%; +1.4%] (no difference)
startup:petclinic:iast:Agent 17.11 s 17.10 s [-0.7%; +0.9%] (no difference)
startup:petclinic:profiling:Agent 16.63 s 16.83 s [-2.2%; -0.1%] (maybe better)
startup:petclinic:sca:Agent 17.11 s 16.99 s [-0.3%; +1.8%] (no difference)
startup:petclinic:tracing:Agent 16.17 s 16.19 s [-0.9%; +0.7%] (no difference)

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

@RoseannaM
RoseannaM marked this pull request as ready for review September 29, 2026 11:38
@RoseannaM
RoseannaM requested a review from a team as a code owner September 29, 2026 11:38
@RoseannaM
RoseannaM requested review from mcculls and removed request for a team September 29, 2026 11:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T11:41:23.854281Z a9e8815 Draft marked ready
🔒 Security Review ✅ Completed 2026-09-29T11:42:52.088427Z a9e8815 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown
Contributor

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

The changed control flow preserves X-Ray context extraction while allowing X-Amzn-Trace-Id to reach the shared header-tag and baggage handling in both codecs.

Was this helpful? React 👍 or 👎

Open Bits AI session

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

@mcculls mcculls left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ValentinZakharov ValentinZakharov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, for exactly this case

However, the same pattern (issue) occures with other special headers:

  • handledUserAgent - User-Agent
  • handledXForwarding - X-Forwarded-Proto/Host/For/Port
  • handledForwarding - Forwarded, Forwarded-For
  • handledIpHeaders - X-Real-IP, True-Client-IP, CF-Connecting-IP, etc + custom IP-header

@ValentinZakharov

Copy link
Copy Markdown
Contributor

Closing in favour of #12695, which fixes the same bug more generally.

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 tag: ai generated Largely based on code generated by an AI or LLM type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants