Skip to content

Add a Kafka enricher benchmark covering both sides of propagation - #13196

Open
dougqh wants to merge 10 commits into
masterfrom
dougqh/kafka-enricher-benchmark
Open

dougqh wants to merge 10 commits into
masterfrom
dougqh/kafka-enricher-benchmark

Conversation

@dougqh

@dougqh dougqh commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #13051: adds a Kafka enricher workload to the Kafka macro benchmark, covering both
sides of propagation on one trace.

From Claude:

The consumer benchmark only extracts, and the producer benchmark only injects (from root spans). The
enricher is the stream-processing shape in between: it consumes the pre-filled topic, appends a few
bytes to each record, and produces it to another topic, one record at a time on one thread. Each
record's consume span continues the upstream trace, and its send gets a child produce span that
injects headers for the next service, so extraction, span creation and injection all run per record.

  • Enricher.java: the consume → transform → produce loop, run as a single source file on Kafka's
    own jars (no build step). Timed from the first record received to the last send acknowledged, so
    startup and the group join are excluded. Exits non-zero if the topic runs dry or any send fails,
    reporting the first failure.
  • run-enricher.sh: same shape as run-consumer.sh (heap sweep, reps, rotating variant order, GC
    logs). Defaults: 3M records, heaps 512m/256m/128m; at 64m the enricher is GC-bound even without
    the agent. ENRICH_COPY_HEADERS=true forwards input headers to the output records, as Kafka
    Streams does, so the tracer replaces its headers rather than adding them.
  • preflight-enricher.sh: checks each output record carries its input record's trace id, i.e. the
    trace continues end to end.
  • Analyze.java summarizes enricher results; common.sh gains ENRICH_TOPIC; README covers the
    three workloads.

First results (one laptop, JDK 17, Agent stub, 3M records, 3 reps, 256m): NoAgent ~702k
records/s; master adds 6.07 µs per record, roughly double the consumer-only cost. Master plus the
Kafka header tweaks (#13165, #13171, #13181, #13182) measured 5.52 µs (+7.9% throughput, runs
non-overlapping), the first workload where the inject-side changes show.

🤖 Generated with Claude Code

@dougqh dougqh added type: feature Enhancements and improvements tag: no release notes Changes to exclude from release notes inst: kafka Kafka instrumentation comp: tooling Build & Tooling tag: ai generated Largely based on code generated by an AI or LLM labels Nov 4, 2026
@dougqh

dougqh commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 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-11-09T17:59:47.294359Z faafd19 Manual request
ℹ️ 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.

@dougqh
dougqh marked this pull request as ready for review November 4, 2026 01:07
@dougqh
dougqh requested a review from a team as a code owner November 4, 2026 01:07
@dougqh
dougqh requested review from ValentinZakharov and removed request for a team November 4, 2026 01:07

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 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: FAIL

The enricher's throughput includes Kafka client shutdown, so group-leave or producer-close delays are reported as record-processing cost.

Open Bits AI session

🤖 Bits Code Review · Commit fc588cb

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc588cb035

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@dd-octo-sts

dd-octo-sts Bot commented Nov 4, 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.99 s [-0.3%; +1.1%] (no difference)
startup:insecure-bank:tracing:Agent 12.99 s 13.02 s [-1.0%; +0.6%] (no difference)
startup:petclinic:appsec:Agent 17.35 s 17.23 s [+0.1%; +1.4%] (maybe worse)
startup:petclinic:iast:Agent 17.15 s 17.19 s [-1.1%; +0.6%] (no difference)
startup:petclinic:profiling:Agent 16.73 s 16.98 s [-2.5%; -0.4%] (maybe better)
startup:petclinic:sca:Agent 16.82 s 17.19 s [-6.6%; +2.3%] (no difference)
startup:petclinic:tracing:Agent 16.42 s 15.89 s [-0.9%; +7.6%] (no difference)

Commit: 95cc9eec · 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 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: faafd19f69

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@datadog-datadog-prod-us1

This comment has been minimized.

@dougqh

dougqh commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@ValentinZakharov @AlexeyKuznetsov-DD gentle nudge on this one when you have a moment. It's harness-only (dd-java-agent/benchmark-integration/kafka, no agent code), CI is green, and it merges cleanly. It adds the enricher workload, which covers both extraction and injection, and the Kafka work in #13600 and the stack above it is measured with it. Thanks!

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD 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.

Approved, left some notes + issues found with Codex.

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 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: FAIL

The PR adds a Kafka consume–transform–produce benchmark covering extraction and injection, with configurable header forwarding and per-record propagation checks. Client-shutdown timing and final-span cleanup are fixed, but the preflight still accepts matching trace IDs when the output span ID is missing.

Open Bits AI session

🤖 Bits Code Review · Commit 91a6566

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 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 PR adds a Kafka consume–transform–produce benchmark covering extraction and injection, with configurable header forwarding and per-record propagation checks. Client shutdown is excluded from timing, final consume-span cleanup is fixed, and preflight now rejects missing span IDs; no reportable findings remain.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 7a461f0

@dougqh

dougqh commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-11-30 20:22:03 UTC ℹ️ Start processing command /merge


2026-11-30 20:22:17 UTC ℹ️ MergeQueue: Pull request is not mergeable yet

It will be processed automatically as soon as GitHub reports it as mergeable. View in MergeQueue UI.

  • Run /code blockers to see what is blocking it.
  • Run /remove to cancel it.

2026-12-01 00:25:08 UTC ⚠️ MergeQueue: This merge request was unqueued

devflow unqueued this merge request: It did not become mergeable within the expected time

dougqh and others added 2 commits November 30, 2026 19:17
The enricher consumes the pre-filled topic, appends a few bytes to each record and produces it to
another topic. Each record's consume span continues the upstream trace and its send gets a child
produce span that injects headers, so extraction and injection are measured on the same trace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s at 128m

A 64m heap leaves the enricher GC-bound even without the agent, because the producer's 32 MB send
buffer takes half of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dougqh and others added 8 commits November 30, 2026 19:17
…irmed one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…output topic

- End the measured window right after producer.flush(), before closing the clients, so consumer
  shutdown (leaving the group) isn't counted as processing.
- Write each run to its own output topic and delete it afterwards; topic retention alone left
  minutes of output on disk, since the broker only checks retention every 5 minutes.
- Let the enricher preflight compare W3C traceparent trace ids when Datadog headers aren't injected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The instrumented iterator finishes a record's consume span only when it
advances or runs out, so breaking after the last counted record left that span
unfinished, and its trace, produce span included, was never written. Finish the
batch that reaches the target instead; the count can exceed it by up to one
poll, and records/s uses the actual count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With forwarded headers, the producer instrumentation starts the produce span
from the upstream context in them, as for Kafka Streams users, so it's a
sibling of the consume span. That's the point of the mode, so say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The enricher preflight compared only each topic's first record and never
passed the copy-headers mode. It now checks all 20 in offset order, needs
a new span id on each output record, reads with --timeout-ms, and deletes
the topics it created however it exits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed delete was silent, so later runs measured alongside the
leftover topic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…codes

Name the parent as the forwarded upstream context, a sibling of the
consume span only without a kafka.deliver span. List the exit codes and
report invalid arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A missing span id parses as '-', which never equals a real input span,
so a record with no output produce span passed the new-span check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh
dougqh force-pushed the dougqh/kafka-enricher-benchmark branch from 7a461f0 to 95cc9ee Compare December 1, 2026 00:32

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 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 preflight checks every record’s trace continuity and span-ID replacement in the selected header mode. Live Kafka behavior and benchmark measurements remain unverified because Kafka is unavailable in the environment.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 95cc9ee

@dougqh

dougqh commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-12-01 01:57:53 UTC ℹ️ Start processing command /merge


2026-12-01 01:57:58 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 58m (p90).


2026-12-01 03:05:22 UTC ❌ MergeQueue: The build pipeline failed for this merge request

Build pipeline has failing jobs for 2ef8f98:

⚠️ 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.

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: tooling Build & Tooling inst: kafka Kafka instrumentation tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants