1. zipkin下载安装
1.1 下载
下载地址:https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=LATEST&c=exec
1.2 安装
java -jar 下载的jar包
1.3 访问
界面地址:http://localhost:9411/zipkin/
2. 链路监控
2.1 pom文件
添加依赖
<!--包含了sleuth+zipkin-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
2.2 yml文件
- 添加链路监控设置
spring:
zipkin:
base-url: http://localhost:9411 # zipkin界面地址
sleuth:
sampler:
#采样率值介于 0 到 1 之间,1 则表示全部采集
probability: 1
2.3 测试
以cloud-provider-payment8001和cloud-consumer-order80为例子
- 8001和80都按照
2.1
和2.2
做一遍操作 - 依次启动7001、8001、80
- 访问http://localhost:808/consumer/payment/getById/2
- 访问http://localhost:9411/