spring cloud 使用zipkin服务链路追踪
yls
2020/5/6
搭建zipkin服务端
1.导入依赖包
<!--服务链路追踪 start-->
<!--zipkin start-->
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
<version>2.10.1</version>
<!--排除日志-->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-starter-log4j2</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<version>2.10.1</version>
</dependency>
<!--zipkin end-->
<!--服务链路追踪 end-->
2.在启动类添加注解 @EnableZipkinServer
3.添加配置文件 application.yml
management:
metrics:
web:
server:
auto-time-requests: false
server:
port: 9411
4.启动服务,浏览器打开 http://localhost:9411
,查看是否成功
添加服务链路追踪客户端使用feign模拟服务调用场景
然后在每个服务客户端中执行如下操作
1.导入依赖包
<!--服务追踪客户端 start-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<!--服务追踪客户端 end-->
2.创建配置文件 application.yml
spring:
zipkin:
base-url: http://localhost:9411 #zipkin服务端的地址