ZipKin
简介
中文文档: https://www.bookstack.cn/read/dyingbleed-zipkin/326d459d6b9268be.md
文档2: ttps://www.springcloud.cc/spring-cloud-greenwich.html#_spring_cloud_sleuth
Zipkin is a distributed tracing system. It helps gather timing data needed to troubleshoot latency problems in service architectures. Features include both the collection and lookup of this data.
Zipkin是一个分布式跟踪系统。 它帮助收集解决服务架构中的延迟问题所需的定时数据。 功能包括数据的收集和查找。
下载地址
https://repo1.maven.org/maven2/io/zipkin/zipkin-server/
运行
上一步下载对应的jar包,输入一下命令运行。
java -jar zipkin-server-2.14.1-exec.jar
打开http://localhost:9411/能看到页面即跑成功
注:如果不做持久化数据在内存中保存,具体如何持久化参考官方文档
Sleuth
依赖
<!--包含了sleuth+zipkin-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
提供者 cloud-provider-payment8001
@GetMapping("/payment/zipkin")
public String paymentZipkin()
{
return "hi ,i'am paymentzipkin server fall back,welcome to my channel,O(∩_∩)O哈哈~";
}
# 添加的配置文件
spring:
zipkin:
base-url: http://localhost:9411
sleuth:
sampler:
#采样率值介于 0 到 1 之间,1 则表示全部采集
probability: 1
消费者 cloud-consumer-order80
@GetMapping("/consumer/payment/zipkin")
public String paymentZipkin()
{
String result = restTemplate.getForObject("http://localhost:8001"+"/payment/zipkin/", String.class);
return result;
}
# 添加的配置文件
spring:
zipkin:
base-url: http://localhost:9411
sleuth:
sampler:
probability: 1
总结
再次访问:http://localhost:9411/即可以看到详细的链路追踪信息