Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I continue using brave headers in spring boot 3 with micrometer

I started migrating to spring boot 3, and also spring-cloud-sleuth to micrometer (https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide#samples).

Added this dependecies:

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-tracing</artifactId>
    <version>${micrometer-tracing.version}</version>
</dependency>
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-tracing-bridge-brave</artifactId>
    <version>${micrometer-tracing.version}</version>
</dependency>

My question is how can I still use the b3 headers ?

Before we were sending this headers:

x-b3-traceid:0c49e38ece42bef5
x-b3-spanid:0c49e38ece42bef5

Now from what I see we have to send this header(https://www.w3.org/TR/trace-context/#trace-flags):

traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-00

Is there additional config that needs to be done in order to use the headers as before ?

like image 985
Master Yi Avatar asked Sep 16 '25 08:09

Master Yi


1 Answers

There are two ways: Use this bean

@Bean
public Tracing braveTracing() {
    return Tracing.newBuilder()
            .propagationFactory(B3Propagation.newFactoryBuilder().injectFormat(B3Propagation.Format.SINGLE_NO_PARENT).build())
            .build();
}

or just add this in application.properties :

management.tracing.propagation.type=b3
like image 102
Master Yi Avatar answered Sep 18 '25 09:09

Master Yi