-
Notifications
You must be signed in to change notification settings - Fork 344
Capture Kafka consumer group membership on join #11989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
piochelepiotr
wants to merge
4
commits into
master
Choose a base branch
from
piotr.wolski/dsm-consumer-group-membership
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d299a2c
Capture Kafka consumer group membership on join for DSM
piochelepiotr 9374995
kafka: skip membership report when cluster id is unknown
piochelepiotr a8ed32a
Fix membership dedup ordering and strip comments from kafka DSM membe…
piochelepiotr 8856963
Restore pre-existing comments accidentally stripped in previous cleanup
piochelepiotr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ts-3.8/src/main/java17/datadog/trace/instrumentation/kafka_clients38/JoinGroupAdvice.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package datadog.trace.instrumentation.kafka_clients38; | ||
|
|
||
| import datadog.trace.bootstrap.InstrumentationContext; | ||
| import datadog.trace.instrumentation.kafka_common.KafkaConfigHelper; | ||
| import datadog.trace.instrumentation.kafka_common.MetadataState; | ||
| import net.bytebuddy.asm.Advice; | ||
| import org.apache.kafka.clients.Metadata; | ||
| import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
| import org.apache.kafka.clients.consumer.internals.ConsumerCoordinator; | ||
|
|
||
| public class JoinGroupAdvice { | ||
| @Advice.OnMethodExit(suppress = Throwable.class) | ||
| public static void trackJoinGroup( | ||
| @Advice.This ConsumerCoordinator coordinator, | ||
| @Advice.Argument(0) final int generationId, | ||
| @Advice.Argument(1) final String memberId, | ||
| @Advice.Argument(2) final String memberProtocol) { | ||
| if (memberId == null || memberId.isEmpty()) { | ||
| return; | ||
| } | ||
| KafkaConsumerInfo kafkaConsumerInfo = | ||
| InstrumentationContext.get(ConsumerCoordinator.class, KafkaConsumerInfo.class) | ||
| .get(coordinator); | ||
| if (kafkaConsumerInfo == null) { | ||
| return; | ||
| } | ||
| if (memberId.equals(kafkaConsumerInfo.getLastReportedMemberId().orElse(null)) | ||
| && generationId == kafkaConsumerInfo.getLastReportedGenerationId()) { | ||
| return; | ||
| } | ||
|
|
||
| String consumerGroup = kafkaConsumerInfo.getConsumerGroup().orElse(null); | ||
| Metadata consumerMetadata = kafkaConsumerInfo.getmetadata().orElse(null); | ||
| String clusterId = null; | ||
| if (consumerMetadata != null) { | ||
| MetadataState metadataState = | ||
| InstrumentationContext.get(Metadata.class, MetadataState.class).get(consumerMetadata); | ||
| clusterId = metadataState != null ? metadataState.clusterId : null; | ||
| } | ||
| if (KafkaConfigHelper.reportConsumerGroupMember( | ||
| clusterId, consumerGroup, memberId, generationId, memberProtocol)) { | ||
| kafkaConsumerInfo.setLastReportedMembership(memberId, generationId); | ||
| } | ||
| } | ||
|
|
||
| public static void muzzleCheck(ConsumerRecord record) { | ||
| record.headers(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.