Search code examples
spring-webfluxspring-cloud-gatewayspring-cloud-sleuthspring-boot-3micrometer-tracing

Spring Boot 3.x with Micrometer Tracing problems for spring-cloud-gateway


We are trying to upgrade our spring-cloud-gateway from Spring Boot 2.7.18 with Sleuth and Brave to 3.1.5. with Micrometer Tracing and Brave. So far so good.

In Spring Boot (Webflux) prior 3 we could use io.projectreactor.netty:reactor-netty-http-brave for adding spanIds and traceIds to HttpClient and HttpServer logs. See: ReactorNettyHttpTracing (deprecated) equivalent in Micrometer Tracing

This approach does not work anymore with micrometer tracing.

We are facing multiple issues:

  • Requests logs from the HttpClient and HttpServer do not contain traceIds or spanIds anymore
  • The Netty access log also does not contain traceIds or spanIds anymore

I created a sample project to demonstrate the issues with JUnit Tests: https://github.com/sandra-markerud/spring-cloud-gateway-upgrade The 'master' branch contains the spring boot 2x version The 'feature/upgrade' branch contains the spring boot 3.1.5 version

Any help would be highly appreciated.

What have I done so far:

Setup according to documentation:

So far, only the following features work:

  • logging of traceId and spanId within "normal" log statements within the application
  • b3 tracing headers are sent in requests to downstream services

Solution

  • So, due to the findings and fixes in #2850, #3003 and spring-boot-3-tracing-coroutine I could finally piece together a working sample:

    spring-cloud-gateway-upgrade with branch 'spring-boot-3.x-upgrade' contains a spring-cloud-gateway in version spring-boot-3-2-1 with logbook 3.7.2.

    The tests show that logging and tracing now finally work correctly depending on logbook being enabled or disabled.

    I hope this helps other people that struggle with the same problems :)