0

I have multiple services running with Spring Boot 2.7 and I am starting to create new services with Spring Boot 3.0. And I have the same problem as in this other question but neither the accepted solution nor the attached migration guide has worked. The behaviour during the requests is the next:

Service (2.7 - TraceId-X) -> Service (3.0 - TraceId-X) => OK
Service (3.0 - TraceId-X) -> Service (3.0 - TraceId-Y) => TraceId-X lost
Service (3.0 - TraceId-X) -> Service (2.7 - TraceId-Y) => TraceId-X lost

In short, when the request starts or goes through a service with version 3.0 the traceId is lost (it has been replaced by a new one).

application.yml (2.7):

spring.sleuth.propagation.type: w3c,b3
spring.sleuth.traceId128: true
spring.sleuth.supportsJoin: false

application.yml (3.0):

logging.pattern.level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"

The versions of the main dependencies are: Services with 2.7 version:

  • spring-boot: 2.7.7
  • spring-cloud-starter-sleuth: 3.1.5

Services with 3.0 version:

  • spring-boot: 3.0.6
  • micrometer-tracing: 1.0.4
  • micrometer-tracing-bridge-brave: 1.0.4

I can understand that there are integration problems between services of different versions, but there are also integration problems between Spring 3.0 services. What could I be missing in the configuration?

Miguel
  • 536
  • 6
  • 20

2 Answers2

1

I do not like to answer my own question but I found the solution and maybe it will help someone in the future.

I did not realise that in most guides and tutorials on the internet they use RestTemplate to communicate between services. In my case, I am using Feign clients. And they need a specific library for micrometer.

<dependency>
  <groupId>io.github.openfeign</groupId>
  <artifactId>feign-micrometer</artifactId>
</dependency>

Reference: https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/#micrometer-support

Miguel
  • 536
  • 6
  • 20
1

you have to update the propagation.type property in spring boot 3 project as well.

management.tracing.propagation.type=b3

and, make sure to add these dependencies.

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

<dependency>
    <groupId>io.zipkin.reporter2</groupId>
    <artifactId>zipkin-reporter-brave</artifactId>
</dependency>
Mafei
  • 3,063
  • 2
  • 15
  • 37
  • Thank you for your answer. I already had those libraries added, I was missing the one I mentioned in my answer. – Miguel Jun 16 '23 at 09:55