spring-bootspring-cloud-sleuthzipkinspring-micrometer

Spring Boot 3 Webflux with Micrometer Tracing not showing as a one trace in the zipkin dashboard


My Microservices application has 3 different Microservices. many of them have been created with just spring boot (imperative way) but those application's tracings are shown in the dashboard correctly. but I created one Microservice application by using spring boot 3 with webflux. because of using spring boot 3 I had to use micrometer instead of sleuth.

My 3rd application does make a http request to the webflux application. but that trace details I can't see in the dashboard under the same trace. that trace (webflux one) is shown as a separate one in the dashboard. other 3 Microservices' tracing details are available under one trace. but webflux's trace is not.

the pom.xml file and configuration like below.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>service-abc</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>service-6</name>
    <description>service-abc</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</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>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-exporter-zipkin</artifactId>
        </dependency>


        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-instrumentation</artifactId>
            <version>3.1.8</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
spring.application.name=service-abc
management.tracing.sampling.probability=1.0
logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]
server.port=5054
logging.level.org.springframework=debug

Main class (according to the doc https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide )


package com.example.service6;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import reactor.core.publisher.Hooks;

@SpringBootApplication
public class Service6Application {

    public static void main(String[] args) {
        SpringApplication.run(Service6Application.class, args);
        Hooks.enableAutomaticContextPropagation();
    }
}

I tried lots of examples in the website but I was unable to do that. please help me to solve this problem.


Solution

  • Add propagation type in your properties file as b3. because zipkin does support B3.

    management.tracing.propagation.type=b3