1.初步了解zipkin和Spring Cloud Sleuth
zipkin:存储跟踪信息
zipkin使用:
//下载
https://search.maven.org/remote_content?g=io.zipkin&a=zipkin-server&v=LATEST&c=exec
//启动zipkin的server端
java -jar zipkin-server-2.23.2-exec.jar
//默认情况下zipkin保存在内存,应该保存在数据库
//IDEA集成zipkin
Spring Cloud Sleuth:跟踪系统
2.IDEA集成zipkin
(1)zuul-simple项目添加依赖
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
(2)配置文件添加rabbitmq和slenuth
spring:
application:
name: spring-cloud-zuul
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
sleuth:
sampler:
probability: 1.0
(3)输入
http://localhost:8080/spring-cloud-producer/hello?name=spring&token=aa
把这个复制去zipkin上查找trace
http://localhost:9411/zipkin/