[fix][client] Fix incorrect topic in OTel spans for partitioned producers - #25896
Conversation
|
@Technoboy- Could you please take a look at this small OpenTelemetry tracing fix when you have time? Thanks! |
could you fix the tests |
you can merge this after the test fixed |
|
The previous CI failure was from the unrelated |
|
branch-4.0 doesn't contain PIP-446, so dropping branch-4.0 as the backporting target. |
Fixes #25897
Motivation
The OTel producer interceptor cached the topic from the first producer it processed.
For partitioned producers, the same interceptor can be used by multiple internal partition producers. For example, if the first message is sent to:
persistent://public/default/my-topic-partition-0the interceptor caches that topic. If a later message is sent to:
persistent://public/default/my-topic-partition-1the producer span could still be created as:
send persistent://public/default/my-topic-partition-0and
messaging.destination.namecould also be reported as:persistent://public/default/my-topic-partition-0This makes OTel producer spans report an incorrect topic for messages sent to other partitions.
Modifications
Use the current producer topic when creating each OTel producer span instead of caching the first topic.
Verifying this change
This change added tests and can be verified as follows:
./gradlew :pulsar-client-original:compileJava./gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.service.OpenTelemetryTracingIntegrationTest.testPartitionedProducerSpanUsesCurrentProducerTopicDoes this pull request potentially affect one of the following parts: