simplyi / SpringCloudVideoCourse

122 stars 300 forks source link

Sleuth and Zipkin dependencies #14

Open hazartilirot opened 1 year ago

hazartilirot commented 1 year ago

~In order to get all parameters in application.yml you need to engage another one dependency~

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
            <version>3.1.7</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin</artifactId>
            <version>3.1.7</version>
        </dependency>

spring:
  zipkin:
    base-url: http://localhost:9411
    sender:
      type: web
  sleuth:
    sampler:
      probability: 1
```~
hazartilirot commented 1 year ago

I'm in the middle of migrating to micrometer metrics. I think Sleuth is no longer supported in Spring Boot 3+

I switched all dependencies to

<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>

then install Zipkin through docker docker run -d -p 9411:9411 openzipkin/zipkin:latest

all parameters in application.properties delete, there would be different: logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]

application.yml

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

then you need to add: application.yml (for .properties file, just use dots to connect parameters instead of colons, and equals for the value at the end)

management:
  tracing:
    sampling:
      probability: 1

Well, I don't know yet how it will go in the future, but right at the moment I have the same result as I'm shown in the lesson Checking Trace ID and Span ID in a Console

Screenshot 2023-04-11 at 00 46 53