Skip to content

[Bug] OTel producer spans can report incorrect topic for partitioned producers #25897

@void-ptr974

Description

@void-ptr974

Search before reporting

  • I searched in the issues and found nothing similar.

Read release policy

  • I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.

User environment

  • Pulsar Java client with OpenTelemetry tracing enabled
  • Partitioned topic producer
  • Broker version is not expected to be specific to this issue

Issue Description

The OTel producer interceptor caches the topic from the first producer it processes.

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-0

the interceptor caches that topic. If a later message is sent to:

persistent://public/default/my-topic-partition-1

the producer span can still be created as:

send persistent://public/default/my-topic-partition-0

and messaging.destination.name can also be reported as:

persistent://public/default/my-topic-partition-0

Expected behavior: OTel producer spans should report the topic of the partition producer that sends the message.

Actual behavior: OTel producer spans can report the topic from a different partition.

Error messages

No error message is produced. The issue is visible in exported OTel span data.

Reproducing the issue

  1. Create a partitioned topic with multiple partitions.
  2. Create a Pulsar Java client with OpenTelemetry tracing enabled.
  3. Create a producer for the partitioned topic.
  4. Send messages to multiple partitions, for example with round-robin routing and batching disabled.
  5. Inspect exported producer spans.

Producer spans for later partitions can contain the first cached partition topic in the span name and messaging.destination.name.

Additional information

Related PR: #25896

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions