Joseph Freeman
Joseph Freeman

Reputation: 1794

Spring Boot v3.1.0 Webflux Micrometer Tracing Logging Trace and Span IDs

I have a Spring Boot service that I am trying to implement tracing using Micrometer Tracing. I assume all I had to do was include the the following in my pom.xml and it would just work:

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-tracing</artifactId>
</dependency>

Adding the above does nothing. I do have Spring Actuator as well. I've tried adding micrometer-tracing-bridge-brave but that was a no go. With Spring Cloud Slueth and everything just worked with autoconfiguration and I've read some post that state Micrometer tracing work with Spring MVC with no additional configuration. My question is how do you configure Micrometer Tracing to work with Spring Webflux? Or is Spring Webflux not supported yet?

Thanks in advance!!

UPDATE:

I've also tried the following in the static void main method:

Hooks.enableAutomaticContextPropagation();

This didn't work either. If anyone has gotten tracing to with using Micrometer an example would be awesome!

Upvotes: 9

Views: 4805

Answers (2)

Irina S.
Irina S.

Reputation: 195

For met it worked with just adding the micrometer-tracing-bridge-brave dependency to my pom.xml file.

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>

Upvotes: 0

Joseph Freeman
Joseph Freeman

Reputation: 1794

Doubling back and providing an answer to my question. I ended up getting this to work. What my issue ended being is the logging pattern for the trace and space ids. The pattern I was using was as follow

%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight{%-5level} %style{[%thread]}{bright} [%style{test-service}{bright blue},%style{%X{traceId:-}}{bright green},%style{%X{spanId:-}}{bright cyan}] %style{%logger{36}}{Magenta} - %msg%n

Notice the traceId and spanId has this following it, :-. Removing the colon dash worked for me. Still not sure why the colon dash breaks it. I hope this helps!

Upvotes: 2

Related Questions