Springboot 使用2.0版本后相应的Zipkin也需要使用2.0版本的,官方建议直接在服务器使用命令运行Zipkin,Zipkin官网安装说明
1.运行起来后访问http://localhost:9411即可访问到如下界面:
2.然后在项目1中POM文件加入:
<!-- 服务追踪 -->
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-zipkin -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-sleuth -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
然后再项目1的YML文件中加入:
spring:
zipkin:
enabled: true
compression:
enabled: true
discovery-client-enabled: true
base-url: https://zuultest.bearead.com/zipkin
sleuth:
enabled: false
sampler:
probability: 1
trace-id128: true
web:
client:
enabled: true
enabled: true
feign:
enabled: true
processor:
enabled: true
messaging:
rabbit:
enabled: true
enabled: true
http:
enabled: true
legacy:
enabled: true
zuul:
enabled: true
log:
slf4j:
enabled: true
scheduled:
enabled: true
hystrix:
strategy:
enabled: true
此时项目1已经完成配置,在配置一个和项目1有交互请求的项目2,项目2配置同上,此时访问项目1由于项目1和项目2有交互查询Zipkin网页监控会发现如下图:
下一篇会介绍怎么让Zipkin使用Mysql存储监控数据,不会因为重启丢失监控数据