通过 RabbitMQ 协议接入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-rabbit</artifactId>
</dependency>
<!-- Zipkin 采用rabbitmq收集数据所需依赖-->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>

二、配置 application.yaml

spring:
    # rabbitmq 配置
    rabbitmq:
        host: 192.168.3.20
        port: 5672
        username: admin
        password: admin
    zipkin:
        enabled: true
        sender:
          # 设置为rabbitmq收集信息,也可以设置为kafka或者web
          type: rabbit
        rabbit:
          # 设置zipkin所用队列,默认是zipkin
          queue: zipkin
    sleuth:
      sampler:
        percentage: 1
        # 将采样比例设置为 1.0,也就是全部都需要。默认是 0.1
        probability: 1.0

参考资料:

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

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