Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

B3 tracing headers with Spring Boot 3 WebClient

Unfortunately Spring Sleuth is not compatible with Spring Boot 3, so I'm looking for a way to pass B3 header with HTTP request done by Spring WebClient.

I think, it should be something like

brave's TracingClientHttpRequestInterceptor, but for Spring WebClient.

or Spring Sleuth's TraceExchangeFilterFunction, but Spring Boot 3.

I also found io.projectreactor.netty:reactor-netty-http-brave as WebClient uses netty, but it seems deprecated.

like image 720
Bademus Avatar asked Oct 24 '25 02:10

Bademus


1 Answers

If you want Spring Boot 3 and Distributed Tracing, you should use Micrometer Tracing instead of Sleuth.

Spring Boot 3.0.0 was released with configuring support for the W3C format. This was possible to override by Java config but now properties were added so that you can set which propagation format you want to use from properties: https://github.com/spring-projects/spring-boot/pull/35611

The supported formats by default were also extended:

management.tracing.propagation.consume // default: [W3C, B3, B3_MULTI]
management.tracing.propagation.produce // default: [W3C]
management.tracing.propagation.type

So if you want to use B3, you can upgrade to the latest version and set management.tracing.propagation.type=B3 or just set management.tracing.propagation.produce=B3.

like image 62
Jonatan Ivanov Avatar answered Oct 26 '25 21:10

Jonatan Ivanov