sleuth link tracking

Basic term
span (span): basic unit of work, send a remote scheduling task, hi generates a span, span is a unique identifier than a 4-digit id
trace (trace): a series of spans form a tree structure and request a microservice The system's api interface, this api interface, needs to call multiple microservices, each microservice called will generate a new span, all the spans generated by this request form a trace
annotation (label): used to record an event in time Yes, some core annotations are used to define the beginning and end of a request. These annotations include the following:

  • cs: client sentm: the client sends a request, this annotation describes the beginning of the span
  • sr: server received The server receives the request and is ready to process it. If you subtract the cs timestamp from the sr, you can get the network transmission time
  • ss server sent: (The server sends a response) This annotation indicates the completion of the request processing (when the request is returned to the client). If the time of ss is wrong and the sr timestamp is subtracted, the time requested by the server can be obtained.
  • cr client received (the client receives the response) At the end of the span, if the timestamp of cr minus the timestamp of cs, the time consumed by the entire request lock can be obtained.

Import dependencies

<!--链路追踪-->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>

Add configuration

spring:
    zipkin:
      base-url: http://localhost:9411
      sender:
        type: web
      # 取消nacos对zipkin的服务发现
      discovery-client-enabled: false
    #采样取值介于 01之间,1则表示全部收集
    sleuth:
      sampler:
        probability: 1
logging:
  level:
    #上线后,可以降低日志级别
    #openfeign链路追踪
    org.springframework.cloud.openfeign: debug
    #sleuth链路追踪
    org.springframework.cloud.sleuth: debug
  1. Query call link
    Insert picture description here

Guess you like

Origin blog.csdn.net/u014496893/article/details/114393170