spring-cloud-stream
spring-cloud-stream copied to clipboard
Trace ID logging inconsistencies across kafka binder and reactor kafka binder
Hi,
I have created the prototype https://github.com/davidmelia/spring-boot-kafka-consumer-tracing to illustrate an issue summarised by
- Trace ID is output OK in the kafka binder depending on where the log statement is in the reactor chain.
- Trace ID is not output in the reactor kafka binder
If you follow the README after hitting http://localhost:8080/sendMessage you will see
... INFO [aid=spring-boot-kafka-consumer-tracing,tid=,sid=,cusname=] 36173 --- [-f567995d3b2a-1] c.e.demo.consumer.TestMessagesConsumer : Reactor Kafka Binder: This log statement does not have the trace id
... INFO [aid=spring-boot-kafka-consumer-tracing,tid=63e4bb48fde4e7bad38152c80451f3e1,sid=7a6ca04b1324a87c,cusname=My Name] 36173 --- [container-0-C-1] c.e.demo.consumer.TestMessagesConsumer : Kafka Binder: This log statement has the trace id
... INFO [aid=spring-boot-kafka-consumer-tracing,tid=,sid=,cusname=] 36173 --- [ parallel-4] c.e.demo.consumer.TestMessagesConsumer : Reactor Kafka Binder: This log statement does not have the trace id
... INFO [aid=spring-boot-kafka-consumer-tracing,tid=,sid=,cusname=] 36173 --- [ parallel-5] c.e.demo.consumer.TestMessagesConsumer : Kafka Binder: This log statement does not have the trace id
I have found no way to get the reactor kafka binder to log the trace ID nor can I get the following statement to log the trace ID in any binder
return Mono.just("OK").delayElement(Duration.ofMillis(10)).doOnSuccess(r -> log.info(...);
Thanks
@patpatpat123 ^^
See some related discussion here: https://github.com/reactor/reactor-kafka/issues/321.
I think even if we don't something in the framework for simple operators, those flatMap, concatMap in the end-user code must be instrumented respectively.
I have the same issue.
Hi, I have updated my prototype in the branch https://github.com/davidmelia/spring-boot-kafka-consumer-tracing/tree/potential_fix using the new reactor Hooks.enableAutomaticContextPropagation(); which simulates the legacy Spring Cloud Sleuth
This solves the issue for the non reactive kafka binder.
Obviously as per the other thread the reactor kafka currently doesn't show trace IDs using this method.
Thanks
Would be great if reactor kafka can leverage the latest micrometer with reactive support on reactor kafka level!
A fix/workaround would be great here?....