Skip to content

Skip DSM tag/context building in Kafka producers when Data Streams is off (dsm - perf quick fix) - #13082

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
dougqh/dsm-guard-kafka-producer
Oct 27, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
dougqh/dsm-guard-kafka-producer

Conversation

@dougqh

@dougqh dougqh commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Skips building Data Streams Monitoring (DSM) tags in the Kafka producer paths (kafka-clients-0.11 and kafka-clients-3.8) when DSM is disabled:

  • Send advice (KafkaProducerInstrumentation / ProducerContextPropagationAdvice): DataStreamsTags were built for every record sent. With DSM off they were used only by the DSM injection, which does nothing then.
  • Producer callback (KafkaProducerCallback, both versions): DataStreamsTags.createWithPartition(...) was built for every acknowledged record and passed to trackBacklog. DefaultDataStreamsMonitoring is used even with DSM off, and its trackBacklog has no enabled check, so each acknowledgement also allocated a Backlog and queued it for the DSM thread to throw away.

All guards use the dynamic traceConfig().isDataStreamsEnabled() check, so turning DSM on through remote config still works.

Not included: the offset-commit paths (ConsumerCoordinator*, DDOffsetCommitCallback) have the same pattern, but run per commit and partition, not per message.

Motivation

In the Kafka consumer, the same guard saved 548 B per record (−13.7% allocation) with DSM off (KafkaConsumeScenariosBenchmark, #13075), and +6.6% throughput in kafka-consumer-perf-test. Most of that is DataStreamsTags.create: prefixed tag strings, hashing, and a byte[] per hashed tag. The producer side does it twice per record: once on send and once on acknowledgement.

Additional Notes

Part of a sweep of the same pattern across messaging integrations, one PR per integration:

With DSM off at startup, the DSM propagator isn't registered, and DataStreamsPropagator.inject also returns early when isDataStreamsEnabled() is false. New spans get NoopPathwayContext, so setCheckpoint does nothing. The skipped work had no observable effect.

Follow-ups: APMLP-2116 (audit), APMLP-2117 (gated contributions, so a disabled product costs one branch by construction), APMLP-2147 (making DataStreamsTags cheap when DSM is on).

Tests: kafka-clients-0.11 + kafka-clients-3.8 test + forkedTest: 228 tests, 0 failures, including the DSM-enabled suites.

Jira ticket: APMLP-2116

🤖 Generated with Claude Code

… off

The send advice built DataStreamsTags for every record, and the producer
callback built DataStreamsTags for every acknowledged record to track
the produce backlog, even with DSM disabled, where DSM injection and
trackBacklog are no-ops. Guard both with the dynamic
isDataStreamsEnabled() check so remote-config enablement still takes
effect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@datadog-official

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 68.82% (+9.34%)

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

@dd-octo-sts

dd-octo-sts Bot commented Oct 27, 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.05 s 14.02 s [-0.5%; +1.0%] (no difference)
startup:insecure-bank:tracing:Agent 12.87 s 13.06 s [-2.1%; -0.8%] (maybe better)
startup:petclinic:appsec:Agent 17.18 s 17.09 s [-0.4%; +1.4%] (no difference)
startup:petclinic:iast:Agent 16.90 s 17.11 s [-2.0%; -0.4%] (maybe better)
startup:petclinic:profiling:Agent 16.81 s 16.74 s [-0.6%; +1.4%] (no difference)
startup:petclinic:sca:Agent 17.17 s 17.01 s [-0.1%; +1.9%] (no difference)
startup:petclinic:tracing:Agent 16.07 s 16.26 s [-2.0%; -0.3%] (maybe better)

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

@dougqh
dougqh marked this pull request as ready for review October 27, 2026 19:38
@dougqh
dougqh requested review from a team as code owners October 27, 2026 19:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-10-27T19:41:10.077411Z d901d4f 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-official datadog-official 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 DSM guards preserve trace propagation, span completion, and user callbacks in both Kafka versions. The completed static review identified no reportable regression.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit d901d4f

@ygree ygree 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.

IDM approved

@dougqh

dougqh commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-27 20:45:09 UTC ℹ️ Start processing command /merge


2026-10-27 20:45:14 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 2h (p90).


2026-10-27 21:34:45 UTC ❌ MergeQueue: The build pipeline contains failing jobs for this merge request

Build pipeline has failing jobs for bc0d1d7:

⚠️ Do NOT retry failed jobs directly (why?).

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.
Details

Since those jobs are not marked as being allowed to fail, the pipeline will most likely fail.
Therefore, and to allow other builds to be processed, this merge request has been rejected and the pipeline got canceled.

@dougqh

dougqh commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-27 22:31:14 UTC ℹ️ Start processing command /merge


2026-10-27 22:31:18 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 2h (p90).


2026-10-27 23:31:07 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 4b6dcdf into master Oct 27, 2026
634 of 643 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the dougqh/dsm-guard-kafka-producer branch October 27, 2026 23:31
@github-actions github-actions Bot added this to the 1.69.0 milestone Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: data streams Data Streams Monitoring inst: kafka Kafka instrumentation tag: ai generated Largely based on code generated by an AI or LLM type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants