3

I am using Sleuth and Zipkin for distributed tracing and facing an issue.

Issue: TraceID and SpanID is not getting printed in the microservice logs (and passed to Zipkin) with 3.0.0 version of Spring Boot.

Following are the versions I am using:

  • Spring Boot version: 3.0.0
  • Spring cloud version: 2021.0.4
  • Zipkin Server version: zipkin-server-2.23.19-exec

application.properties:

spring.application.name=sleuthpoc2
spring.zipkin.base-url=http://localhost:9411/
spring.sleuth.sampler.probability=1.0
spring.zipkin.sender.type=WEB
win32trojan
  • 37
  • 1
  • 8
  • Does this answer your question? [Zipkin not working in Docker - conncection refused](https://stackoverflow.com/questions/74877968/zipkin-not-working-in-docker-conncection-refused) – mini Mar 20 '23 at 07:54

2 Answers2

5

As we describe it in https://github.com/spring-cloud/spring-cloud-sleuth/tree/main

Spring Cloud Sleuth’s last minor version is 3.1. You can check the 3.1.x branch for the latest commits.

The core of this project got moved to Micrometer Tracing project and the instrumentations will be moved to Micrometer and all respective projects (no longer all instrumentations will be done in a single repository.

You can check the migration guide here https://github.com/micrometer-metrics/tracing/wiki/Spring-Cloud-Sleuth-3.1-Migration-Guide on how to migrate away from Sleuth to Micrometer Tracing.

Marcin Grzejszczak
  • 10,624
  • 1
  • 16
  • 32
  • Hi Marcin, are you talking about the Sleuth version? If I got it right then I need to use 3.1 version of sleuth with Spring boot 3.0.0 version. Please confirm – win32trojan Nov 30 '22 at 09:04
  • 2
    As I wrote in the answer, Sleuth 3.1.x is the last version that we release. It's Boot 2.x compatible. There's no version of Sleuth that is Boot 3.x compatible. You would need to migrate to Micrometer Tracing in order to use Boot 3.0 – Marcin Grzejszczak Nov 30 '22 at 11:48
  • @Marcin Grzejszczak does Micrometer support openFeign (for brave & zipkin) – UN..D Dec 20 '22 at 21:28
  • Micrometer Observation was added to Feign 12.1 https://github.com/OpenFeign/feign/commit/72f379a03d24826ae64e43a3d3e737c2a94ee717 – Marcin Grzejszczak Dec 28 '22 at 21:56
  • I tried this successfully. but how we can change the ```zipkin.sender.type``` in new way. because I was unable to find that in the doc. – Mafei May 13 '23 at 00:18
2

Had the same issue with spring boot 3. Removed sleuth dependency and added micrometer dependecy. Able to get trace and span ID in the logs. Below are the sample codes:

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

      <appender class="ch.qos.logback.core.ConsoleAppender" name="stdout">
       <encoder>
         <pattern>
            %d{yyyy-MM-dd} | %d{HH:mm:ss.SSS} | %thread | %5p | %logger{25} | %12(ID: %8mdc{id}) | %X{traceId:-} | "%X{spanId:-}" | appName | %m%n 
        </pattern>
    </encoder>
    </appender>
     <appender class="ch.qos.logback.core.ConsoleAppender" name="jsonstdout">
       <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
        <providers>
            <timestamp>
                <timeZone>EST</timeZone>
                 <timestampPattern>yyyy-MM-dd'T'HH:mm:ss.SSS</timestampPattern>
            </timestamp>
                <pattern>
                <pattern>
                    {
                        "service" : "appName",
                        "level": "%p",
                        "thread": "%thread",
                        "trace": "%X{traceId:-}",
                        "span": "%X{spanId:-}",
                        "class": "%logger{40}",
                        "message": "%m"
                    }
                </pattern>
            </pattern>
            <stackTrace>
                <throwableConverter 
           class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
                    <maxDepthPerThrowable>30</maxDepthPerThrowable>
                    <maxLength>2048</maxLength>
                    <shortenedClassNameLength>20</shortenedClassNameLength>
                    <rootCauseFirst>true</rootCauseFirst>
                </throwableConverter>
            </stackTrace>
        </providers>
    </encoder>
</appender>
Procrastinator
  • 2,526
  • 30
  • 27
  • 36
Kuppusamy
  • 65
  • 1
  • 6