Skip to content

Format extracted ids as hex only if read - #13140

Draft
dougqh wants to merge 2 commits into
dougqh/shared-sampling-statesfrom
dougqh/lazy-extracted-id-hex
Draft

dougqh wants to merge 2 commits into
dougqh/shared-sampling-statesfrom
dougqh/lazy-extracted-id-hex

Conversation

@dougqh

@dougqh dougqh commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Extraction no longer formats hex strings for ids that are usually never read as hex. One commit each:

  1. The extracted Datadog parent id is formatted only if read.
    • The extraction cache turned x-datadog-parent-id into a 16-character hex string on every extraction. Only a W3C span id override reads it, as _dd.parent_id.
    • The cache now keeps the parsed long and formats it on demand. It still parses as each header arrives, so invalid values are still skipped when the header repeats.
  2. The traceparent trace id is built from its parsed parts.
    • DD128bTraceId.fromHex kept a 32-character substring of the traceparent as the id's cached hex form, once per extraction.
    • Both parse paths now read the high and low order bits the same way. The id is built with DD128bTraceId.from(high, low), which formats its hex lazily and caches it.

Motivation

Ids unique to a trace or span shouldn't be formatted or cached unless they're read. In the Kafka consumer macro benchmark (#13051, JFR allocation profile, 10M records), ExtractionCache.cacheDatadogSpanId alone accounts for about 0.2 GB of String allocation.

  • Leaf services no longer allocate either string.
  • Services that inject W3C downstream still format the trace id hex, once per trace, as before.

No JMH numbers yet. The propagation tests and the compound-extraction golden corpus (which covers _dd.parent_id) pass unchanged.

Additional Notes

Stacked on #13043.

🤖 Generated with Claude Code

dougqh and others added 2 commits October 30, 2026 17:01
The extraction cache formatted x-datadog-parent-id as 16 hex characters on
every extraction, though only a W3C span id override reads it. Keep the
parsed id and format it on demand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DD128bTraceId.fromHex kept a substring of the traceparent as the id's cached
hex form, one per extraction. Build the id from its high and low order bits,
which both parse paths now read the same way, so its hex form is formatted
only if read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 30, 2026
@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 59.99% (-0.02%)

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

@dd-octo-sts

dd-octo-sts Bot commented Oct 30, 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.90 s [+0.3%; +1.7%] (maybe worse)
startup:insecure-bank:tracing:Agent 12.86 s 13.02 s [-1.8%; -0.5%] (maybe better)
startup:petclinic:appsec:Agent 17.65 s 17.42 s [+0.4%; +2.2%] (maybe worse)
startup:petclinic:iast:Agent 17.50 s 17.12 s [-2.0%; +6.4%] (no difference)
startup:petclinic:profiling:Agent 17.33 s 17.20 s [-0.3%; +1.9%] (no difference)
startup:petclinic:sca:Agent 17.70 s 17.47 s [+0.3%; +2.4%] (maybe worse)
startup:petclinic:tracing:Agent 16.55 s 16.63 s [-1.6%; +0.6%] (no difference)

Commit: bddcbf27 · 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 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