Skip to content

Fix duplicate Pulsar multi-topic receive spans#18771

Open
trask wants to merge 2 commits into
open-telemetry:mainfrom
trask:fix-pulsar-multitopic-receive-duplicates
Open

Fix duplicate Pulsar multi-topic receive spans#18771
trask wants to merge 2 commits into
open-telemetry:mainfrom
trask:fix-pulsar-multitopic-receive-duplicates

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented May 17, 2026

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.

@trask trask marked this pull request as ready for review May 17, 2026 23:16
@trask trask requested a review from a team as a code owner May 17, 2026 23:16
Copilot AI review requested due to automatic review settings May 17, 2026 23:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 MultiTopicsConsumerImpl from ConsumerImplInstrumentation.typeMatcher() so only ConsumerImpl produces receive spans (listener-suppression instrumentation in ConsumerBaseInstrumentation still covers MultiTopicsConsumerImpl).
  • Add testReceiveMultiTopics that 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants