Skip to content

Merge a W3C trace context from the header cache without running its interpreter - #13651

Draft
dougqh wants to merge 1 commit into
dougqh/kafka-value-viewsfrom
dougqh/w3c-merge-from-constants
Draft

dougqh wants to merge 1 commit into
dougqh/kafka-value-viewsfrom
dougqh/w3c-merge-from-constants

Conversation

@dougqh

@dougqh dougqh commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

When the Datadog headers have already given a context, compound extraction merges the W3C trace context into it. With a carrier that knows each key's header constant (the composite propagator's cache), the merge now reads traceparent and tracestate straight from it, instead of running the W3C interpreter over every cached header. Extracted contexts are unchanged.

Stacked on #13620.

Additional Notes

  • Same handling as the interpreter:

    • traceparent is trimmed, and a second traceparent means no context to merge;
    • each tracestate is trimmed, and the non-empty ones are joined with ,;
    • neither header present means nothing to merge.
  • Same parse: the interpreter's traceparent parse is split into static helpers (validateTraceParent, traceParentTraceId, traceParentSpanId, traceParentPriority) that both paths call, and the tracestate parse is unchanged.

  • Falls back to the interpreter when header names are being logged, or when the carrier has a trace context key without a constant (a key the composite cache couldn't classify).

  • A mismatched trace id still builds the whole W3C context, for the span link (through extract, which gives what completeExtraction did).

  • Tests (ExtractorKeysForkedTest.mergingFromHeaderConstantsMatchesInterpretingEveryKey): runs the full compound-extraction corpus through both paths and checks the contexts are identical. That's every traceparent against every tracestate, with Datadog headers matching, mismatching or absent, and all priorities and tags. CompoundExtractionGoldenTest passes unchanged.

  • Numbers (KafkaFetchedHeadersBenchmark, same 5-vCPU Linux Xeon, JDK 21, BASE and this PR each run twice, interleaved, 5 forks per run): medians of all 10 forks per cell, since the sandbox was noisy in some runs:

    appHeaders shape BASE (Hand parse-only Kafka header values to extraction as views #13620) this PR change
    0 fetchedAccessor 4657 4419 −5.1%
    0 fetched 4712 4754 +0.9%
    0 built 4402 4266 −3.1%
    3 fetchedAccessor 4744 4608 −2.9%
    3 fetched 4920 4838 −1.7%
    3 built 4492 4432 −1.3%

    The interpreter run was a modest part of the merge's cost; most of it is parsing, which Check tracestate members in one pass and skip t.* keys the merge never reads #13610 and Read only the priority and parent id from a lower-priority W3C tracestate #13650 address. With Read only the priority and parent id from a lower-priority W3C tracestate #13650's change stacked on top (same runs), fetchedAccessor is about −10% vs BASE.

🤖 Generated with Claude Code

@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 23, 2026
@dougqh
dougqh force-pushed the dougqh/w3c-merge-from-constants branch from eff7d17 to 752072b Compare November 23, 2026 21:17
@dougqh
dougqh force-pushed the dougqh/kafka-value-views branch from cf19f37 to afee6bc Compare November 23, 2026 21:17
@datadog-datadog-prod-us1

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

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 85.33%
• Overall Coverage: 59.70% (+0.02%)

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

@dd-octo-sts

dd-octo-sts Bot commented Nov 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.06 s 13.95 s [+0.3%; +1.4%] (maybe worse)
startup:insecure-bank:tracing:Agent 12.96 s 13.07 s [-1.6%; -0.1%] (maybe better)
startup:petclinic:appsec:Agent 17.81 s 17.66 s [-0.3%; +1.9%] (no difference)
startup:petclinic:iast:Agent 17.72 s 17.69 s [-0.8%; +1.1%] (no difference)
startup:petclinic:profiling:Agent 17.58 s 17.54 s [-1.1%; +1.5%] (no difference)
startup:petclinic:sca:Agent 17.42 s 17.10 s [-4.0%; +7.9%] (unstable)
startup:petclinic:tracing:Agent 16.85 s 16.86 s [-1.2%; +1.0%] (no difference)

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

@pr-commenter

pr-commenter Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Kafka / producer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch dougqh/kafka-value-views dougqh/w3c-merge-from-constants
git_commit_sha effc650 4cd9ccf
See matching parameters
Baseline Candidate
ci_job_date 1795555108 1795555108
ci_job_id 2298331819 2298331819
ci_pipeline_id 156344243 156344243
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
git_commit_date 1795553626 1795553626
jdkVersion 11.0.31 11.0.31
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=15002 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=15002 -Dhttp.nonProxyHosts=localhost *.localhost
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-1-mgde59sc 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-1-mgde59sc 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaProduceBenchmark.benchProduce same

@dougqh
dougqh force-pushed the dougqh/w3c-merge-from-constants branch from 752072b to e23c679 Compare November 23, 2026 23:36
@dougqh
dougqh force-pushed the dougqh/kafka-value-views branch from afee6bc to 20f4cf5 Compare November 23, 2026 23:36
@dougqh
dougqh force-pushed the dougqh/w3c-merge-from-constants branch from e23c679 to 3c580c3 Compare November 23, 2026 23:47
@dougqh
dougqh force-pushed the dougqh/kafka-value-views branch from 20f4cf5 to 019c24c Compare November 23, 2026 23:47
@pr-commenter

pr-commenter Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Kafka / consumer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch dougqh/kafka-value-views dougqh/w3c-merge-from-constants
git_commit_sha effc650 4cd9ccf
See matching parameters
Baseline Candidate
ci_job_date 1795555148 1795555148
ci_job_id 2298331821 2298331821
ci_pipeline_id 156344243 156344243
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
git_commit_date 1795553626 1795553626
jdkVersion 11.0.31 11.0.31
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=15002 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=15002 -Dhttp.nonProxyHosts=localhost *.localhost
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-1-kwxr1g8m 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-1-kwxr1g8m 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaConsumerBenchmark.benchConsume unsure
[-12213.968op/s; -1903.976op/s] or [-3.894%; -0.607%]
scenario:only-tracing-dsm-enabled-benchmarks/KafkaConsumerBenchmark.benchConsume unsure
[+236.619op/s; +10061.755op/s] or [+0.130%; +5.531%]

@dougqh
dougqh force-pushed the dougqh/kafka-value-views branch from 019c24c to f1f822e Compare November 24, 2026 02:33
@dougqh
dougqh force-pushed the dougqh/w3c-merge-from-constants branch from 3c580c3 to aeb9b36 Compare November 24, 2026 02:33
@dougqh
dougqh force-pushed the dougqh/kafka-value-views branch from f1f822e to 65a1922 Compare November 24, 2026 18:30
@dougqh
dougqh force-pushed the dougqh/w3c-merge-from-constants branch from aeb9b36 to 9f359c0 Compare November 24, 2026 18:30
@dougqh
dougqh force-pushed the dougqh/kafka-value-views branch from 65a1922 to e6f4a95 Compare November 24, 2026 20:10
@dougqh
dougqh force-pushed the dougqh/w3c-merge-from-constants branch from 9f359c0 to 100f7f1 Compare November 24, 2026 20:10
…terpreter

When the Datadog headers have already given a context, compound extraction only
needs a few parts of the W3C trace context to merge into it, but ran the W3C
interpreter over every cached header to get them. With a carrier that knows
each key's header constant (the composite propagator's cache), the merge now
reads traceparent and tracestate straight from it: the same handling as the
interpreter (trimming, multiple traceparents, joined tracestates), the same
traceparent parse, now shared as static helpers, and the same tracestate parse.

A mismatched trace id still builds the whole W3C context, for the span link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh
dougqh force-pushed the dougqh/kafka-value-views branch from e6f4a95 to effc650 Compare November 24, 2026 21:00
@dougqh
dougqh force-pushed the dougqh/w3c-merge-from-constants branch from 100f7f1 to 4cd9ccf Compare November 24, 2026 21:00

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