Fix duplicate Pulsar multi-topic receive spans#18771
Open
trask wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Pulsar's MultiTopicsConsumerImpl was being instrumented with the same receive advice as the per-topic ConsumerImpl, causing duplicate "receive" spans (one for each underlying single-topic consumer and another for the multi-topic wrapper). This PR narrows ConsumerImplInstrumentation to only the per-topic class and adds a regression test.
Changes:
- Drop
MultiTopicsConsumerImplfromConsumerImplInstrumentation.typeMatcher()so onlyConsumerImplproduces receive spans (listener-suppression instrumentation inConsumerBaseInstrumentationstill coversMultiTopicsConsumerImpl). - Add
testReceiveMultiTopicsthat asserts exactly one receive span per logical message when consuming from a multi-topic subscription.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ConsumerImplInstrumentation.java | Restrict type matcher to ConsumerImpl, removing duplicate receive-span instrumentation on the multi-topic consumer. |
| PulsarClientTest.java | New regression test verifying one receive span per message via a multi-topic consumer. |
The partitioned batch receive test expected a single base-topic receive metric point and read metrics without waiting. Partitioned consumers report receive message counts per partition, so the assertion failed once partition attributes were emitted. Update the test to wait for the receive metric and validate the per-partition point counts and attributes from the received messages. Validation: .\gradlew.bat :instrumentation:pulsar:pulsar-2.8:javaagent:spotlessCheck :instrumentation:pulsar:pulsar-2.8:javaagent:testClasses
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Prevent Pulsar multi-topic consumers from being instrumented as receive sources in addition to their underlying per-topic consumers. Add a regression test that receives two messages through a multi-topic consumer and asserts one receive span per logical message.