SpringCloud Sleuth distributed request link tracking

concept

1. 为什么需要链路追踪?
在微服务框架中,一个由客户端发起的请求在后端系统中
会经过多个不同的的服务节点调用来协同产生最后的请求结果,
每一个前段请求都会形成一复杂的分布式服务调用链路,
链路中的任何一环出现高延时或错误都会引起整个请求最后的失败。

2. Spring Cloud Sleuth提供了一套完整的服务跟踪的解决方案

3. 在分布式系统中提供追踪解决方案并且兼容支持了zipkin

4. 提供了jar包供安装使用,web图形界面,监控微服务请求经过了哪些链路。
流向。

https://github.com/spring-cloud/spring-cloud-sleuth

use

  1. Download
    https://dl.bintray.com/openzipkin/maven/io/zipkin/java/zipkin-server/

  2. Glossary

Trace:类似于树结构的Span集合,表示一条调用链路,存在唯一标识
span:表示调用链路来源,通俗的理解span就是一次请求信息

Services that need to be tracked

provider

<!--包含了sleuth+zipkin-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>


spring:
  application:
    name: cloud-payment-service
  zipkin:
    base-url: http://localhost:9411
  sleuth:
    sampler:
    probability: 1

consumer

 <!--包含了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

Access a request of the microservice consumer, open the zipkin interface, and view the flow of the request.

http:localhost:9411

Guess you like

Origin blog.csdn.net/qq_44783283/article/details/111411577