3

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 ?

xMilos
  • 1,519
  • 4
  • 21
  • 36

1 Answers1

2

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
xMilos
  • 1,519
  • 4
  • 21
  • 36
  • `B3Propagation.Format.SINGLE_NO_PARENT` does not get old headers, you need to set it to `B3Propagation.Format.MULTI` – Víctor Herraiz Mar 10 '23 at 15:42
  • @VíctorHerraiz I use the bean approach and it works for me with SINGLE_NO_PARENT. MULTI probably will generate both b3 and w3c. – xMilos Mar 13 '23 at 07:52
  • https://javadoc.io/doc/io.zipkin.brave/brave/latest/brave/propagation/B3Propagation.Format.html MULTI uses `x-b3-` fields as requested in the query – Víctor Herraiz Mar 13 '23 at 11:29
  • It seems like another breaking change, I wonder if it is documented or not as indeed with sb 2.* it was MULTI – Artem Ptushkin May 23 '23 at 10:25
  • you can use MULTI or SINGLE_NO_PARENT depending on what you need. – xMilos May 25 '23 at 07:54