spring-bootobservablespring-kafkaspring-micrometer

Where can I find the place where Spring Boot kafka listener is setting the TraceId?


I'm searching for the file where Spring Boot Kafka listener is placing en deciding if the TraceId is collected from the header or it has to create a new one. I have debugged now for many hours but can't find the place? Can any one help me?


Solution

  • First of all Spring Boot and Spring for Apache Kafka are different projects. While the first one uses the second, but it does that only for auto-configuration of respective components from the second one. So, please, be careful when you call projects from your questions.

    Spring for Apache Kafka uses Micrometer Observation, where indeed one of the handler is for tracing. See more info in the respective docs: https://docs.spring.io/spring-kafka/reference/appendix/micrometer.html.

    The observation information is collected from the ConsumerRecord by the KafkaRecordReceiverContext. However, the decision about creating new trace or restore existing from just collected is done in the PropagatingReceiverTracingObservationHandler implementation. And this one is a part of the mentioned Micrometer Tracing. Nothing to do with Spring at all.