通过 Kafka 协议接入Zipkin

一、添加Maven依赖包

<!-- For Spring Cloud Zipkin(Zipkin依赖) -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<!-- For Spring Cloud Sleuth(服务跟踪依赖) -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-stream-kafka</artifactId>
</dependency>
<!-- Zipkin 采用kafka收集数据所需依赖-->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency>

二、配置 application.yaml

spring:
    # kafka集群地址
    kafka:
        bootstrap-servers: 192.168.3.20
    zipkin:
        enabled: true
        sender:
          # 设置为kafka收集信息,也可以设置为rabbitmq或者web
          type: kafka
        kafka:
          # kafka的topic,默认则为zipkin
          queue: zipkin
    sleuth:
      sampler:
        percentage: 1
        # 将采样比例设置为 1.0,也就是全部都需要。默认是 0.1
        probability: 1.0

参考资料:

https://blog.csdn.net/k_young1997/article/details/104239086
https://blog.csdn.net/UckyK/article/details/103779928

作者:Jeebiz  创建时间:2023-03-16 23:06
最后编辑:Jeebiz  更新时间:2023-03-20 16:51