spring boot 1.5.12 版本的 zipkin 链路追踪整合使用

依赖的环境:mysq rabbit elasticsearch

1、zipkin 服务端 pom 需要引入的jar

org.springframework.cloud
spring-cloud-sleuth-zipkin-stream


org.springframework.cloud
spring-cloud-starter-sleuth


org.springframework.cloud
spring-cloud-stream-binder-rabbit

    
        io.zipkin.java
        zipkin-autoconfigure-ui
        2.8.4
    


io.zipkin.java
zipkin-autoconfigure-collector-rabbitmq
2.8.4

    
    

    
    
        io.zipkin.java
        zipkin-autoconfigure-storage-mysql
        2.6.1
    
    
        mysql
        mysql-connector-java
    
    
        org.springframework.boot
        spring-boot-starter-jdbc
    
    
        com.alibaba
        druid
        1.1.9
    

2、zipkin 服务端 application.yml 中的配置

server:
port: 9411

spring:
application:
name: jplat-zipkin-server
datasource:
name: zipkin
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://10.130.5.109:3306/zipkin?characterEncoding=utf8&useSSL=true
username: root
password: 123456
schema: classpath:/zipkin.sql
continue-on-error: true
rabbitmq:
host: 192.168.213.130
port: 5672
username: rabbit
password: 123456
sleuth:
sampler:
percentage: 1.0 #默认的采样比率为0.1,不能看到所有请求数据,可以在每个客户端的application.yml中加入下面的配置,更改采样比率为1,就能看到所有的请求数据了,但是这样会增加接口调用延迟
enabled: false

zipkin:
storage:
type: mysql
#type: elasticsearch
#StorageComponent: elasticsearch
#elasticsearch:
#cluster: elasticsearch
#hosts: 192.168.213.130:9200
#hosts: 192.168.0.102:9200
#max-requests: 64
#index: zipkin
#index-shards: 5
#index-replicas: 1

collector:
rabbitmq:
uri: amqp://rabbit:[email protected]:5672
#uri: amqp://rabbit:[email protected]:5672
queue: zipkin

eureka:
client:
service-url:
defaultZone: http://localhost:28080/eureka/

3、zipkin 服务端 启动类中配置


image.png

4、每个微服务端的pom中需要引入的jar

org.springframework.cloud
spring-cloud-starter-zipkin
1.3.3.RELEASE

    
        org.springframework.boot
        spring-boot-starter-amqp
    

5、每个微服务端的application.yml 中新增配置项
rabbitmq:
host: 192.168.213.130
#host: 192.168.0.102
port: 5672
username: rabbit
password: 123456
zipkin:
service:
name: ${spring.application.name}
sender:
type: rabbit
sleuth:
#messaging:
#rabbit:
#enabled: true
sampler:
percentage: 1.0

6、访问zipkin
http://127.0.0.1:9411/zipkin/

你可能感兴趣的:(spring boot 1.5.12 版本的 zipkin 链路追踪整合使用)