Skip to content

Capture Kafka consumer group membership on join - #11989

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 6 commits into
masterfrom
piotr.wolski/dsm-consumer-group-membership
Aug 5, 2026
Merged

Capture Kafka consumer group membership on join#11989
gh-worker-dd-mergequeue-cf854d[bot] merged 6 commits into
masterfrom
piotr.wolski/dsm-consumer-group-membership

Conversation

@piochelepiotr

@piochelepiotr piochelepiotr commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

What

Instruments ConsumerCoordinator.onJoinComplete (kafka-clients 0.11 + 3.8) so that every time a consumer (re)joins a group the tracer reports its broker-assigned member id, generation id, and negotiated member protocol through Data Streams Monitoring, alongside the consumer group and Kafka cluster id.

  • New AgentDataStreamsMonitoring.reportKafkaConsumerGroupMember(...); carried on the DSM payload as first-class fields (MemberId, GenerationId, MemberProtocol) on the existing kafka config report — no new payload section.
  • Change-detection on (memberId, generationId) avoids re-reporting unchanged membership.

Motivation

The agent integration collects member ID --> [(topic, partition), ...] collection

However, users don't know what a member ID is. This PR adds the correlation member ID --> Infra tags (pod, host, etc).

That way, a user will be able to correlate a specific partition with a specific pod. (high lag on a partition & high CPU on the corresponding pod ==> probably a hot partition.

Instrument ConsumerCoordinator.onJoinComplete (kafka-clients 0.11 and 3.8)
to report the broker-assigned member id, generation id and negotiated
member protocol each time a consumer (re)joins a group. Reported through
Data Streams Monitoring alongside the consumer group and cluster id via a
new reportKafkaConsumerGroupMember path (member_host is not available
client-side and is intentionally omitted).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@piochelepiotr piochelepiotr added tag: ai generated Largely based on code generated by an AI or LLM inst: kafka Kafka instrumentation comp: data streams Data Streams Monitoring type: feature Enhancements and improvements labels Jul 17, 2026
@datadog-datadog-prod-us1

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Jul 17, 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 13.98 s 13.84 s [+0.2%; +1.7%] (maybe worse)
startup:insecure-bank:tracing:Agent 12.89 s 12.92 s [-0.8%; +0.4%] (no difference)
startup:petclinic:appsec:Agent 17.56 s 17.37 s [-0.1%; +2.2%] (no difference)
startup:petclinic:iast:Agent 17.54 s 17.64 s [-1.3%; +0.3%] (no difference)
startup:petclinic:profiling:Agent 17.45 s 17.53 s [-1.9%; +0.9%] (no difference)
startup:petclinic:sca:Agent 17.66 s 17.54 s [-0.3%; +1.6%] (no difference)
startup:petclinic:tracing:Agent 16.51 s 16.68 s [-1.8%; -0.2%] (maybe better)

Commit: ef81ea39 · 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 Jul 17, 2026

Copy link
Copy Markdown

Kafka / producer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master piotr.wolski/dsm-consumer-group-membership
git_commit_date 1784298512 1785955021
git_commit_sha e98ec49 ef81ea3
See matching parameters
Baseline Candidate
ci_job_date 1785956441 1785956441
ci_job_id 1926701491 1926701491
ci_pipeline_id 129238369 129238369
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
jdkVersion 11.0.25 11.0.25
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
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.25+9-post-Ubuntu-1ubuntu122.04 11.0.25+9-post-Ubuntu-1ubuntu122.04

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 unsure
[+33.950op/s; +2863.845op/s] or [+0.023%; +1.979%]

@pr-commenter

pr-commenter Bot commented Jul 17, 2026

Copy link
Copy Markdown

Kafka / consumer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master piotr.wolski/dsm-consumer-group-membership
git_commit_date 1784298512 1784672388
git_commit_sha e98ec49 8856963
See matching parameters
Baseline Candidate
ci_job_date 1784673473 1784673473
ci_job_id 1880741066 1880741066
ci_pipeline_id 126116544 126116544
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
jdkVersion 11.0.25 11.0.25
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 -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/go/src/github.com/DataDog/apm-reliability/dd-trace-java/platform/src/consumer-benchmark/build/tmp/jmh -Duser.country=US -Duser.language=en -Duser.variant -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/go/src/github.com/DataDog/apm-reliability/dd-trace-java/platform/src/consumer-benchmark/build/tmp/jmh -Duser.country=US -Duser.language=en -Duser.variant
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.25+9-post-Ubuntu-1ubuntu122.04 11.0.25+9-post-Ubuntu-1ubuntu122.04

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

@piochelepiotr
piochelepiotr marked this pull request as ready for review July 17, 2026 21:15
@piochelepiotr
piochelepiotr requested review from a team as code owners July 17, 2026 21:16
@piochelepiotr
piochelepiotr requested review from ygree and removed request for a team July 17, 2026 21:16

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

Datadog Autotest: WARN

The PR instruments Kafka consumer group membership tracking but introduces a breaking msgpack format change: all kafka configs now serialize with 7 fields (adding MemberId, GenerationId, MemberProtocol) instead of 4. Downstream consumers that expect exactly 4 fields will fail to parse the new format, potentially breaking the entire DSM kafka pipeline. The PR claims cross-repo coordination, but without deployment verification, this is a critical downstream compatibility risk.

📊 Validated against 6 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit d299a2c · What is Autotest? · Any feedback? Reach out in #autotest

@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: d299a2cbf1

ℹ️ 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".

A membership report can't be attributed downstream without a cluster id, so
skip it (the kafka_consumer integration reports the member with the cluster id
and the tracer re-reports on the next rejoin) rather than emit an empty-cluster row.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@piochelepiotr
piochelepiotr force-pushed the piotr.wolski/dsm-consumer-group-membership branch from 6e64884 to 9374995 Compare July 20, 2026 14:47
piochelepiotr and others added 2 commits July 21, 2026 16:12
…rship reporting

Only mark a membership as reported once reportConsumerGroupMember
actually attempts the report (i.e. cluster id is known), instead of
marking it unconditionally before the cluster-id check. Also aligns
generationId serialization with writeInt/unpackInt used elsewhere for
int fields, and removes redundant/duplicated comments introduced by
the feature.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
}

@Nullable
public String getLastReportedMemberId() {

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.

Minor: Similar to how the setLastReportedMembership() method sets both the memberId and the generationId in a single call, there could be a method to check if the membership has changed instead of using two separate getters.

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

LGTM

piochelepiotr and others added 2 commits August 5, 2026 12:18
…2103)

Remove check for JAVA_TOOLS_OPTIONS in verifyAgentJarIntegrations

Co-authored-by: sarah.chen <sarah.chen@datadoghq.com>
@piochelepiotr
piochelepiotr requested a review from a team as a code owner August 5, 2026 18:38
@piochelepiotr
piochelepiotr requested a review from mcculls August 5, 2026 18:38

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

Datadog Autotest: FAIL

When DSM is disabled during a consumer's initial join, the new helper returns success without sending the membership and the advice permanently records that tuple as reported. If DSM is enabled later, the member ID and generation remain absent until another rebalance changes the tuple, delaying the intended pod-to-partition correlation.

View proposed fix
📊 Validated against 5 scenarios · Open Bits AI session

🤖 Datadog Autotest · Commit ef81ea3 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@piochelepiotr

Copy link
Copy Markdown
Contributor Author

When DSM is disabled during a consumer's initial join, the new helper returns success without sending the membership and the advice permanently records that tuple as reported. If DSM is enabled later, the member ID and generation remain absent until another rebalance changes the tuple, delaying the intended pod-to-partition correlation.

@datadog-datadog-prod-us1

I don't see this as a bug. DSM tracks member joins. If member joins happen outside of the time DSM is enabled, then we don't track them.

@piochelepiotr
piochelepiotr enabled auto-merge August 5, 2026 19:11
@piochelepiotr
piochelepiotr added this pull request to the merge queue Aug 5, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 5, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-05 19:29:08 UTC ℹ️ Start processing command /merge


2026-08-05 19:29:13 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-08-05 20:21:08 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 5, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 8031b40 into master Aug 5, 2026
596 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the piotr.wolski/dsm-consumer-group-membership branch August 5, 2026 20:21
@github-actions github-actions Bot added this to the 1.66.0 milestone Aug 5, 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: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants