Skip to content

Fix duplicate Pulsar multi-topic receive spans#18771

Merged
laurit merged 5 commits into
open-telemetry:mainfrom
trask:fix-pulsar-multitopic-receive-duplicates
Jun 17, 2026
Merged

Fix duplicate Pulsar multi-topic receive spans#18771
laurit merged 5 commits into
open-telemetry:mainfrom
trask:fix-pulsar-multitopic-receive-duplicates

Conversation

@trask

@trask trask commented May 17, 2026

Copy link
Copy Markdown
Member

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

Copilot AI 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.

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.

trask added 3 commits May 22, 2026 12:44
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
The partitioned batch receive test sent ten unkeyed messages, so Pulsar could
route multiple messages to each partition and the delta receive metric polling
could observe partial per-partition counts. Route one keyed message to each
partition and assert the batch size before validating the per-partition metric
attributes and counts.

Validation: .\gradlew.bat :instrumentation:pulsar:pulsar-2.8:javaagent:spotlessCheck :instrumentation:pulsar:pulsar-2.8:javaagent:testClasses
@trask

trask commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

Got the sporadic failure that seems to point to this on #18968: https://scans.gradle.com/s/ccbtlli3fpqio

@laurit laurit enabled auto-merge (squash) June 17, 2026 13:24
@laurit laurit merged commit 44d16b1 into open-telemetry:main Jun 17, 2026
95 checks passed
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.

3 participants