An overview,

  • In micro service framework, a request by the client in the back-end system will go through a number of different service node calls to collaborate last request as a result, every paragraph request form a complex distributed service call link, link to any part of the high latency or mistakes can cause the failure of the entire request finally.

  • The official
  • Spring Cloud Sleuth provides a complete set of service tracking solutions
  • Provides tracking solutions in distributed systems and supports Zipkin compatibility

1. The term

  • Before we do that, a few terms
    • Trace: A tree-like Span collection that represents a call link and has a unique identifier
    • Span: indicates the source of the call link. Generally speaking, span is a request information
  • A link is uniquely identified by the Trace Id. A Span identifies the request information. Each Span is associated with the parent Id

Second, the installation

  • You can download the Zipkin JAR package directly and run it from the command
Java jar zipkin - server - 2.12.9 - exec. JarCopy the code
  • For convenience, docker is directly used here. Thank you for your sharing.
docker run -d -p 9411:9411 openzipkin/zipkin
Copy the code
  • After downloading and running, you can open the monitor interface directly in your browser.
http://192.168.233.139:9411/zipkin/
Copy the code

Third, the experiment

  • Add zipkin to service callers and callees on the link for monitoring. Everything is based on service registration, service discovery, and service invocation in the previous sections.

1. The package

  • First, add a package
<! -- Contains sleuth+zipkin-->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
Copy the code

2. Modify the configuration file

spring:
  zipkin:
    base-url: http://localhost:9411
  sleuth:
    sampler:
      # Sampling rate value is between 0 and 1, 1 means all collection
     probability: 1
Copy the code

3. The test

  • Send a request to the service at the link head node several times.
  • Open zikpin to check the status

  • You can see the time spent on each service above.
  • You can also click on the dependencies above to see the current dependencies between the spans. (But I can’t open it here, I don’t know why)