Skip to content

Propagate W3C baggage through Kafka clients - #13860

Open
mcculls wants to merge 10 commits into
masterfrom
mcculls/kafka-baggage-propagation
Open

mcculls wants to merge 10 commits into
masterfrom
mcculls/kafka-baggage-propagation

Conversation

@mcculls

@mcculls mcculls commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Preserves W3C baggage while processing Kafka records, forwarding messages, and running producer completion callbacks, in both Kafka client instrumentations.

Motivation

Kafka extracted baggage but discarded it when activating the consumer span, and producers injected only the span. This prevented applications from reading and forwarding received baggage.

Additional Notes

Uses the existing baggage configuration and OpenTelemetry-compatible baggage header format: a percent-encoded W3C baggage string stored as UTF-8 bytes.

Legacy iteration scopes can now carry a full context while retaining their existing cleanup and timeout behavior. Also corrects shared baggage decoding so literal + characters survive extraction.

Validation: baggage and iteration-scope regressions, baseline and latest Kafka dependency tests, existing trace/context-swap and producer lifecycle tests, shared baggage decoding on Java 8, and Spotless checks.

@mcculls mcculls added type: bug fix Bug fix comp: context propagation Trace context propagation inst: kafka Kafka instrumentation tag: ai generated Largely based on code generated by an AI or LLM labels Dec 5, 2026
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 60.00%
• Overall Coverage: 60.42% (-1.54%)

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

Preserve baggage during record consumption, downstream sends, and
producer callbacks using the existing UTF-8 baggage header format.

Allow legacy iteration scopes to carry full contexts and preserve
literal plus signs during baggage decoding.
Use the existing literal replacement helper only for baggage strings
containing plus signs, and share record-versus-caller baggage precedence
in the Kafka common helper.

Align the new regressions with repository conventions.
Suppress caller baggage for invalid spans at injection time, including
the retry for read-only record headers.
@dd-octo-sts

dd-octo-sts Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Java Benchmark SLOs — Performance SLO warning (near threshold)

Suite Status
Startup 🟡 warning

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.90 s 14.76 s [+0.1%; +1.7%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.66 s 13.74 s [-1.3%; +0.2%] (no difference)
startup:petclinic:appsec:Agent 17.83 s 17.76 s [-0.4%; +1.2%] (no difference)
startup:petclinic:iast:Agent 17.82 s 17.88 s [-1.4%; +0.7%] (no difference)
startup:petclinic:profiling:Agent 16.94 s 17.30 s [-6.3%; +2.2%] (no difference)
startup:petclinic:sca:Agent 17.89 s 17.79 s [-0.5%; +1.6%] (no difference)
startup:petclinic:tracing:Agent 16.80 s 17.06 s [-2.6%; -0.5%] (maybe better)

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

@mcculls
mcculls force-pushed the mcculls/kafka-baggage-propagation branch from 37de857 to 7f78ff1 Compare December 5, 2026 15:46
@mcculls mcculls added type: feature Enhancements and improvements and removed type: bug fix Bug fix labels Dec 5, 2026
@mcculls
mcculls force-pushed the mcculls/kafka-baggage-propagation branch from 55db763 to dc22da0 Compare December 5, 2026 17:09
@mcculls
mcculls force-pushed the mcculls/kafka-baggage-propagation branch from 091840f to d2e64ae Compare December 5, 2026 17:42
@mcculls
mcculls marked this pull request as ready for review December 5, 2026 17:42
@mcculls
mcculls requested review from a team as code owners December 5, 2026 17:42
@mcculls
mcculls requested review from ValentinZakharov and jbachorik and removed request for a team December 5, 2026 17:42
@mcculls
mcculls requested a review from Mascarpone December 5, 2026 17:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-05T17:45:58.611493Z d2e64ae 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-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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

Static analysis raised no concrete defect in Kafka baggage forwarding, callback context restoration, or iteration-scope handling. Runtime behavior remains unverified because tests were not executed and production telemetry was excluded.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit d2e64ae

@pr-commenter

pr-commenter Bot commented Dec 5, 2026

Copy link
Copy Markdown

Kafka / producer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master mcculls/kafka-baggage-propagation
git_commit_date 1796426129 1796492525
git_commit_sha 417736a d2e64ae
See matching parameters
Baseline Candidate
ci_job_date 1796493560 1796493560
ci_job_id 2332312514 2332312514
ci_pipeline_id 157875821 157875821
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
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-0-k0krlk0j 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-0-k0krlk0j 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

@pr-commenter

pr-commenter Bot commented Dec 5, 2026

Copy link
Copy Markdown

Kafka / consumer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master mcculls/kafka-baggage-propagation
git_commit_date 1796426129 1796492525
git_commit_sha 417736a d2e64ae
See matching parameters
Baseline Candidate
ci_job_date 1796493468 1796493468
ci_job_id 2332312515 2332312515
ci_pipeline_id 157875821 157875821
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
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-0-fgrre2fq 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-0-fgrre2fq 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 same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaConsumerBenchmark.benchConsume same

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 inst: kafka Kafka instrumentation tag: ai generated Largely based on code generated by an AI or LLM type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant