<dependency>
<groupId>io.jaegertracing</groupId>
<artifactId>jaeger-client</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-kafka-client</artifactId>
<version>0.1.13</version>
</dependency>
kafka:
producer:
properties:
interceptor:
classes: io.opentracing.contrib.kafka.TracingProducerInterceptor
kafka:
consumer:
properties:
interceptor:
classes: io.opentracing.contrib.kafka.TracingConsumerInterceptor
@KafkaListener(topics = "${TOPIC_NAME}")
public void listen(ConsumerRecord<String, String> record) {
SpanContext spanContext = TracingKafkaUtils.extractSpanContext(record.headers(), tracer);
}
ProducerRecord<String, Object> producerRecord = new ProducerRecord<>(responseTopic, responseMessage);
TracingKafkaUtils.inject(span.context(), producerRecord.headers(), tracer);
kafkaTemplate.send(producerRecord);