Skip to content

traceId is not propagated on kafka #65

@codecraft21

Description

@codecraft21

Describe the bug
The traceId is not propagated to Kafka.
Spring Boot 2.5.2
Spring Cloud 2020.0.3
Spring Cloud Sleuth OTel 1.0.0-M8

Sample
See https://github.com/codecraft21/demo-tracing
master branch: generated from start.spring.io + added Sleuth OTel according to its doc
When calling the / endpoint, another endpoint is called (traceId is propagated on http) and then a kafka message is produced.
The consumer has no traceId.

2021-06-26 19:25:12.209  INFO [,b062f82be4a37b87f96916d298f9a41a,296ab729c3b3ed95] 10856 --- [nio-8080-exec-3] c.codecraft.demo.tracing.DemoController  : Handling home
2021-06-26 19:25:12.212  INFO [,b062f82be4a37b87f96916d298f9a41a,0f3000fc63a58f61] 10856 --- [nio-8080-exec-8] c.codecraft.demo.tracing.DemoController  : generated uuid 19008618-ced3-439a-aa47-28575f21ec7e
2021-06-26 19:25:12.213  INFO [,b062f82be4a37b87f96916d298f9a41a,296ab729c3b3ed95] 10856 --- [nio-8080-exec-3] c.codecraft.demo.tracing.DemoController  : produced kafka 19008618-ced3-439a-aa47-28575f21ec7e
2021-06-26 19:25:12.216  INFO [,,] 10856 --- [container-0-C-1] ch.codecraft.demo.tracing.AsyncService   : received 'some data 19008618-ced3-439a-aa47-28575f21ec7e' with headers: RecordHeaders(headers = [], isReadOnly = false)

brave branch: same setup but without OTel, only Sleuth default. And in that case the traceId is propagated to Kafka.

2021-06-26 19:26:17.916  INFO [,ee08855bbd16bed9,ee08855bbd16bed9] 21112 --- [nio-8080-exec-5] c.codecraft.demo.tracing.DemoController  : Handling home
2021-06-26 19:26:17.918  INFO [,ee08855bbd16bed9,d56b43ff83467b4d] 21112 --- [nio-8080-exec-2] c.codecraft.demo.tracing.DemoController  : generated uuid 510314f5-64a0-4005-b171-6759483bf065
2021-06-26 19:26:17.919  INFO [,ee08855bbd16bed9,ee08855bbd16bed9] 21112 --- [nio-8080-exec-5] c.codecraft.demo.tracing.DemoController  : produced kafka 510314f5-64a0-4005-b171-6759483bf065
2021-06-26 19:26:17.922  INFO [,ee08855bbd16bed9,cf0d4734f3375490] 21112 --- [container-0-C-1] ch.codecraft.demo.tracing.AsyncService   : received 'some data 510314f5-64a0-4005-b171-6759483bf065' with headers: RecordHeaders(headers = [], isReadOnly = false)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions