Skip to content

Kafka ProducerRecord may end up with duplicated trace headers #3095

Closed as not planned
@GFriedrich

Description

@GFriedrich

Describe the issue
I found a bit of a weird behaviour when enabling the observation on Spring Integrations and the Spring Kafka binder.
In this case the Spring Integration already adds a traceparent header (e.g. when using W3C traces) to the internal Message but later on the Spring Kafka binder will also add another traceparent header.

To Reproduce
Steps to reproduce the behavior:

  1. Enable the observation for Spring Integrations via spring.integration.management.observation-patterns
  2. Enable Spring Kafka binder observations via spring.cloud.stream.kafka.binder.enable-observation
  3. Send a message to a StreamBridge
  4. See that the produced record on Kafka has two traceparent headers

Version of the framework
4.2.0

Expected behavior
There should be just one traceparent header on a produced record.

Additional context
Even though it is already possible to handle that in a way by suppressing the header from the Spring Integration via spring.cloud.stream.kafka.default.producer.header-patterns it would be great to see a more permanent solution.
I would suggest to either:

  • add a default exclusion for traceparent headers to the BinderHeaderMapper implementation (potentially also other headers would be needed then in case people use something different than W3C headers)
  • or make the KafkaRecordSenderContext to first remove the same existing header and replacing it instead of just adding new ones

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions