1.部署zipkin-server
zipkin下载地址:Quickstart · OpenZipkin https://zipkin.io/pages/quickstart.html
下载后是个jar,运行jar包,默认端口9411,访问地址:http://127.0.0.1:9411。
2.pom.xml中增加依赖
<!--服务追踪-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
3.application.yml中增加配置
spring:
zipkin:
base-url: http://127.0.0.1:9411
sleuth:
sampler:
rate: 1
sleuth:
sampler:
probability: 1
enabled: true
4.最后,测试即可