Comments on: Kafka Tracing with Spring Boot and Open Telemetry https://piotrminkowski.com/2023/11/15/kafka-tracing-with-spring-boot-and-open-telemetry/ Java, Spring, Kotlin, microservices, Kubernetes, containers Wed, 02 Oct 2024 21:28:48 +0000 hourly 1 https://wordpress.org/?v=6.9.1 By: krpors https://piotrminkowski.com/2023/11/15/kafka-tracing-with-spring-boot-and-open-telemetry/#comment-2511 Wed, 02 Oct 2024 21:28:48 +0000 https://piotrminkowski.com/?p=14669#comment-2511 In reply to piotr.minkowski.

FYI for future readers, the thing that made it work was indeed the code supplied by Tommaso. Specifically, creating a custom @Bean(“factory”), then using it in the @KafkaListener(containerFactory = “factory”).

Thanks a lot, because I had been on this issue for a loooong day.

]]>
By: piotr.minkowski https://piotrminkowski.com/2023/11/15/kafka-tracing-with-spring-boot-and-open-telemetry/#comment-2363 Thu, 14 Mar 2024 08:12:39 +0000 https://piotrminkowski.com/?p=14669#comment-2363 In reply to Tommaso.

Hi. But what exactly did you change? Just added that line: factory.getContainerProperties().setMicrometerEnabled(true); ?

]]>
By: Tommaso https://piotrminkowski.com/2023/11/15/kafka-tracing-with-spring-boot-and-open-telemetry/#comment-2359 Tue, 12 Mar 2024 14:06:31 +0000 https://piotrminkowski.com/?p=14669#comment-2359 Hi, thanks for the great post. Unfortunately the consumer part doesn’t work properly.
I found a workaround that I would like to share. These are the fixes:

@Bean(“factory”)
public ConcurrentKafkaListenerContainerFactory listenerFactory(ConsumerFactory consumerFactory) {
ConcurrentKafkaListenerContainerFactory factory =
new ConcurrentKafkaListenerContainerFactory();
factory.getContainerProperties().setObservationEnabled(true);
factory.getContainerProperties().setMicrometerEnabled(true);
factory.setConsumerFactory(consumerFactory);
returnfactory;
}

@Service
public class ListenerService {
private static final Logger LOG = LoggerFactory.getLogger(ListenerService.class);
@KafkaListener(id = “info”, topics = “${app.in.topic}”, containerFactory = “factory”)
public void onMessage(@Payload Info info,
@Header(name = KafkaHeaders.RECEIVED_KEY, required = false) Long key,
@Header(KafkaHeaders.RECEIVED_PARTITION) int partition) {
LOG.info(“Received(key={}, partition={}): {}”, key, partition, info);
}

}
Greetings

]]>
By: piotr.minkowski https://piotrminkowski.com/2023/11/15/kafka-tracing-with-spring-boot-and-open-telemetry/#comment-2271 Tue, 30 Jan 2024 13:02:47 +0000 https://piotrminkowski.com/?p=14669#comment-2271 In reply to Artem.

The library add trace id and span id headers to the messages

]]>
By: Artem https://piotrminkowski.com/2023/11/15/kafka-tracing-with-spring-boot-and-open-telemetry/#comment-2267 Wed, 24 Jan 2024 03:19:30 +0000 https://piotrminkowski.com/?p=14669#comment-2267 Thanks. Please explain from where the consumer gets the producers trace id? I.e. what makes the spans actually work together.

]]>
By: piotr.minkowski https://piotrminkowski.com/2023/11/15/kafka-tracing-with-spring-boot-and-open-telemetry/#comment-2251 Mon, 15 Jan 2024 11:59:27 +0000 https://piotrminkowski.com/?p=14669#comment-2251 In reply to Jean.

No. But I know that currently Spring team works on the simplifying it onside the Spring Kafka. With Spring Boot 3.2 you can use YAML/properties instead of the `setObservationEnabled` method.

]]>
By: piotr.minkowski https://piotrminkowski.com/2023/11/15/kafka-tracing-with-spring-boot-and-open-telemetry/#comment-2250 Mon, 15 Jan 2024 11:57:35 +0000 https://piotrminkowski.com/?p=14669#comment-2250 In reply to Balazs.

Ok, thanks for that suggestion.

]]>
By: piotr.minkowski https://piotrminkowski.com/2023/11/15/kafka-tracing-with-spring-boot-and-open-telemetry/#comment-2249 Mon, 15 Jan 2024 11:56:21 +0000 https://piotrminkowski.com/?p=14669#comment-2249 In reply to Jagan Singh.

In order to achive it, we should override the default Spring Boot log format (e.g. the `logging.pattern.console` property). Maybe in the future, the Spring Boot Kafka autoconfiguration will do that.

]]>
By: Jagan Singh https://piotrminkowski.com/2023/11/15/kafka-tracing-with-spring-boot-and-open-telemetry/#comment-2245 Wed, 10 Jan 2024 13:15:29 +0000 https://piotrminkowski.com/?p=14669#comment-2245 but why trace id’s are not visible in logs

]]>
By: Jean https://piotrminkowski.com/2023/11/15/kafka-tracing-with-spring-boot-and-open-telemetry/#comment-2226 Tue, 02 Jan 2024 23:02:22 +0000 https://piotrminkowski.com/?p=14669#comment-2226 Hi, I think what you described here can be achieved in an easier, non-programmatic way with pure opentelemetry agents without micrometer. Have you explored this approach or is there something that I’m missing that micrometer is truly adding here?

]]>