How to configure zipkin baseUrl in SpringBoot 3
Asked Answered
O

2

6

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.

Overglaze answered 16/3, 2023 at 16:6 Comment(0)
T
14

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:

  • connect-timeout
  • endpoint
  • read-timeout

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

management:
  zipkin:
    tracing:
      endpoint: <url to collector>:9411/api/v2/spans
Taliataliaferro answered 18/3, 2023 at 16:17 Comment(1)
Thanks for the answer Daniel. I wanted to know how did you deduce that the issue would be through Spring Boot actuator for configprops? I am learning tracing through SpringBoot and wanted to know more details about it.Camouflage
V
0

for springboot 3.0.X i added the following dependency in pom.xml:

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

for the connection with the zipkin server I added the following configuration:

  • management.zipkin.tracing.connect-timeout=1s
  • management.zipkin.tracing.encoding=[JSON]
  • management.zipkin.tracing.endpoint=http://ADRSSS_IP_SERVER_ZIPKIN:9411/api/v2/spans
  • management.zipkin.tracing.read-timeout=10s

of course for the logback pattern you have to trace the traceid and spanid : example : [serviceName, traceId:%X{traceId}, spanId:%X{spanId}]

my question: for me the zipkin server does not trace all the traceid values ​​recorded in the log, despite the addition of :

spring.sleuth.sampler.probability: "1.0"

Has anyone encountered the same problem?

Villon answered 4/10 at 9:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.