javaspring-boottracespring-cloud-sleuthmicrometer-tracing

Tracing in RabbitListener - observationEnabled


migrating from SpringBoot 2 to SpringBoot 3.1 in an application that uses @RabbitListener the tracing information relating to TraceId and SpanId no longer appears in the logs.
I used the new classes also forcing the generation

   Tracer tracer = Tracer.NOOP;
    Span span = tracer.currentSpan();
   span = tracer.nextSpan();

but it didn't help.

About the documentation:

Using Micrometer for observation is now supported, since version 3.0.5, for the RabbitStreamTemplate and the stream listener container. The container now also supports Micrometer timers (when observation is not enabled).

Set observationEnabled on each component to enable observation; this will disable Micrometer Timers because the timers will now be managed with each observation. When using annotated listeners, set observationEnabled on the container factory.

Has anyone had a similar problem?


Solution

  • (I only speak Chinese, the following is the translation) I am upgrading from 2.7 to 3.1, and now I have added a bean, you can try it

    @Bean
    ContainerCustomizer<SimpleMessageListenerContainer> containerCustomizer() {
        return container -> container.setObservationEnabled(true);
    }