spring 链路监控

sleuth负责整理, zipkin负责展现

 

1.安装zipkin

下载jar包:  https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=LATEST&c=exec

运行jar

 

 访问主页成功: http://localhost:9411/zipkin/ 

 

 

 

2. 代码

在需要被监控的微服务下都引入以下pom和yml:

        <!--引入springCloud链路调用监控 包含sleuth和zipkin-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>
spring:
  application:
    name: cloud-order-service
  zipkin:
    base-url: http://localhost:9411
  sleuth:
    sampler:
      probability: 1   #采样率值范围是0-1, 1则表示全部采集

 

3.测试:

访问:http://localhost/consumer/payment/get/31

再看zipkin就能查找到调用链路

 

 

github代码:

 https://github.com/lulu4pix/springcloud/commit/2dfca7b668c309e2258803b2b325c0e0f1c87c0f

posted @ 2021-05-29 16:31  圣金巫灵  阅读(158)  评论(0编辑  收藏  举报