javaspring-bootspring-cloudzipkinmicrometer-tracing

How to trace HTTP requests in Spring Boot 3 with Micrometer & Zipkin


My purpose is to trace every request to my system. I watched 2 video below on Youtube to config Micrometer & Zipkin for tracing.

But, when I access http://localhost:9411/zipkin/, it worked abnormally and make me confused.

enter image description here

So I have some questions about it:

  1. At first, I never perform any requests, why there are so many request on Zipkin dashboard?
  2. I use Postman to perform three requests (1 from order-service, 2 from product-service), why it only show the requests from order-service like this enter image description here
  3. Why the spans (Zipkin dashboard) always is 1. Although every requests must go through api-gateway service first, it is not the same as video 1.

For Micrometer config, I reference Micrometer and Zipkin: How to Trace HTTP Requests in Spring Boot 3

I insert management.tracing.sampling.probability=1.0 to each application.properties file and these dependencies below to each pom.xml

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-observation</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-tracing-bridge-brave</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.reporter2</groupId>
            <artifactId>zipkin-reporter-brave</artifactId>
        </dependency>

This is my architecture system:

enter image description here


Solution

  • First, I try to check management.tracing.sampling.probability=1.0, and it raise a error:

    Cannot resolve configuration property 'management.tracing.sampling.probability' 
    

    I really don't understand why it like that, after that I found the different, there are 2 denpendencie, they look pretty similar:

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-actuator</artifactId>
            </dependency>
    
            ...................
            ...................
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
    

    I try to reach out the spring docs: actuator.micrometer-tracing.tracer-implementations and I realize the dependency I actually need is spring-boot-starter-actuator

    I insert three new dependencies from docs:

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <dependency>
                <groupId>io.micrometer</groupId>
                <artifactId>micrometer-tracing-bridge-otel</artifactId>
            </dependency>
            <dependency>
                <groupId>io.opentelemetry</groupId>
                <artifactId>opentelemetry-exporter-zipkin</artifactId>
            </dependency>
    

    To summary, we will use these dependencies for tracing http request with Micrometer & Zipkin.