spring-bootspring-cloud-sleuthzipkinjaegermicrometer-tracing

How to configure zipkin baseUrl in SpringBoot 3


We have Jaeger setup to trace calls primarily between the istio proxies. I'm trying to use tracing inside the application, include any traceId/spanIds in the logs and report back to the Jaeger collector any spans created within the application.

Most of our microservices still run Spring Boot 2. Some are already upgraded to Spring Boot 3.

I've got it to work satisfactory within Spring Boot2.

I included the following dependencies:

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency>
  <groupId>io.opentracing.brave</groupId>
  <artifactId>brave-opentracing</artifactId>
</dependency>

And set the following in the application.yaml

spring:
  application:
    name: our-service
  sleuth:
    propagation:
      type: B3,W3C
    opentracing:
      enabled: true
  zipkin:
    base-url: <url to our jaeger collector>:9411

For our spring boot 3 application I added the following dependencies instead of the ones above:

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

And added the same configuration to the application.yaml as above, but have additionally added:

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

When I have both applications running in our test environment, I can see the traceIds showing up in the logs of both applications and I can find those traceIds in the jaeger UI as well, including spans created within the SpringBoot 2 application. Except for the spanId that is supposed to come from the SpringBoot 3 application. That application has the matching traceIds in the logs, but I also have the following error:

2023-03-16T15:36:15.037Z WARN [our-service,,] 1 --- [ender@207ff82c}] z.r.AsyncReporter$BoundedAsyncReporter : Dropped 1 spans due to ResourceAccessException(I/O error on POST request for "http://localhost:9411/api/v2/spans": Connection refused

Which makes me conclude that the configuration to set the url to the Jaeger collector should be different in Spring Boot 3 as it is not picking up my configured url, but uses http://localhost. But I can't seem to find anywhere how I'm supposed to configure it.

Hoping anyone here can help me out and can tell me what I'm doing wrong.


Solution

  • I recently encountered the same issue. While investigating, I found a solution by looking into the output of the Spring Boot actuator endpoint for configuration properties: http://localhost:8080/actuator/configprops

    The output mentioned a class called ZipkinProperties, so I looked it up in the Spring Boot API documentation: https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/actuate/autoconfigure/tracing/zipkin/ZipkinProperties.html

    There are 3 properties in the class ZipkinConfiguration:

    What you're looking for is the property management.zipkin.tracing.endpoint

    management:
      zipkin:
        tracing:
          endpoint: <url to collector>:9411/api/v2/spans