Skip to content

Write the injecting span's id into tracestate without formatting a String - #13669

Draft
dougqh wants to merge 1 commit into
dougqh/tracestate-lower-priority-mergefrom
dougqh/span-id-hex-once
Draft

dougqh wants to merge 1 commit into
dougqh/tracestate-lower-priority-mergefrom
dougqh/span-id-hex-once

Conversation

@dougqh

@dougqh dougqh commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Writes the injecting span's id into the W3C tracestate's p element straight from the long, instead of formatting it into a padded hex String first.

PaddedHexSpanId is a small CharSequence holding the id. W3CPTagsCodec.appendPrefix recognizes it and appends its 16 digits directly into the header it is building. The parent-id override is only ever measured (length()) and appended, so no API changes. The header is byte-identical: the compound extraction golden, which records every injected header, is unchanged.

Motivation

The W3C injector passed DDSpanId.toHexStringPadded(spanId), which costs a byte[] and a String per injection, only for the encoder to copy them into the header. In a JFR profile of a Kafka enricher this formatting was about 3% of inject time. It's a small item from the Kafka per-record cost work.

Results

InjectorBenchmark.injectContext (default inject styles, Datadog + W3C), 3 forks × 5 iterations:

base this PR
allocation 10,357 ± 45 B/op 10,220 ± 13 B/op (−137 B)

Quiet re-run (3 forks × 5 iterations): 17.31 ± 0.20 → 17.23 ± 0.16 µs/op (no change within error), allocation 10,348 → 10,214 B/op (−134 B). So it saves allocation without costing time.

Additional Notes

🤖 Generated with Claude Code

…ring

The W3C injector passed the span's id for the tracestate's p element as
DDSpanId.toHexStringPadded, a byte array and a String per injection that the
encoder then copied into the header. PaddedHexSpanId carries the id as a long
and the encoder appends its 16 digits directly. The header is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh dougqh added comp: core Tracer core tag: performance Performance related changes type: refactoring tag: ai generated Largely based on code generated by an AI or LLM labels Nov 24, 2026
@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🎯 Code Coverage (details)
• Patch Coverage: 94.12%
• Overall Coverage: 59.88% (+0.01%)

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

@dd-octo-sts

dd-octo-sts Bot commented Nov 24, 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 14.01 s [-0.4%; +0.8%] (no difference)
startup:insecure-bank:tracing:Agent 12.94 s 13.00 s [-1.2%; +0.3%] (no difference)
startup:petclinic:appsec:Agent 17.04 s 16.93 s [-0.2%; +1.6%] (no difference)
startup:petclinic:iast:Agent 16.99 s 17.07 s [-1.3%; +0.3%] (no difference)
startup:petclinic:profiling:Agent 16.03 s 16.17 s [-6.8%; +5.0%] (unstable)
startup:petclinic:sca:Agent 17.08 s 16.98 s [-0.2%; +1.5%] (no difference)
startup:petclinic:tracing:Agent 16.21 s 16.22 s [-0.9%; +0.7%] (no difference)

Commit: 3bf3c469 · 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: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: performance Performance related changes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant