How to use spring cloud sleuth traceId in kafka consumers

Viewed 256

I am using springboot 2.3.4, corresponding spring-kafka 2.5.6.RELEASE, springcloud sleuth 2.2.5, I use @KafkaListener to listen for Kafka messages, but during the test I found that the producer has a traceId, and I need the consumer to generate a new traceId, but unfortunately there is no traceId in the log print. I am a novice, which makes me very confused. Do I need to enable certain configurations, or I need to implement trace by myself? thanks!!

 @KafkaListener( topics = {"#{'${kafka.topics}'}"}, containerFactory = "batchMessageFactory")
    public void onMessage(List<ConsumerRecord<String, String>> records) {
        if(!CollectionUtils.isEmpty(records)) {
         
            records.stream().forEach(record -> {
                String message = record.value();
                log.info("messge:{}",message)
            }
            });
        }

0 Answers
Related