当前位置:网站首页>Sleuth + Zipkin

Sleuth + Zipkin

2022-06-23 16:05:00 weixin_ forty-three million seven hundred and sixty-six thousan

1. sleuth What is it? ?

  • Spring Cloud Sleuth It provides a distributed tracking solution for microservices .
  • Sleuth For distributed link tracing, only trace data is generated , These data are not easy to read , So the tracking data is usually uploaded to Zipkin Server, from Zipkin adopt UI The interface displays data uniformly .

2. sleuth What makes up ?

  • span( span ): Basic work unit . Use one 64 Bit id Unique identification . except id Outside ,span There are other data , For example, describe 、 Timestamp event 、 Comments on key value pairs ( label ),spanId、parentId etc. .

  • trace( track ):trace It's a group. span A tree structure of composition , Use one 64 Bit id Unique identification ,trace All in span Share the trace Of id.

  • traceId : Assigned to a request ID Number , Used to identify a request link .

  • spanId : A basic unit of work , A request can contain multiple steps , Each step has its own spanId. A request contains a TraceId, Multiple SpanId.

3. Zipkin What is it? ?

  • Zipkin It is a distributed real-time data tracking system . Its main function is to collect the time series data of the system , So as to track the system delay of the microservice architecture , Monitoring and tracking link calls ,Zipkin It also provides a very friendly UI Interface , To help analyze the tracking data .
  • Zipkin It provides pluggable data storage mode :In-Memory、MySql、Cassandra as well as Elasticsearch.

4. zipkin What makes up ?

 Insert picture description here

  • Collector: Collector as , It is mainly used to process tracking information sent from external systems , Convert this information to Zipkin Internally processed Span Format , To support subsequent storage 、 analysis 、 Display and other functions .

  • Storage: Storage component , It mainly processes the trace information received by the collector , This information is stored in memory by default , We can also modify this storage policy , Store trace information into the database by using other storage components .

  • RESTful API:API Components , It is mainly used to provide external access interface . For example, display tracking information to clients or access external system to realize monitoring, etc .

  • Web UI:UI Components , be based on API Upper application of component implementation , adopt UI Component users can easily and intuitively query and analyze tracking information .

5. Sleuth + Zipkin Implement the distributed link tracking process ?

  • Zipkin Divided into two ends , One is Zipkin Server side , One is Zipkin client , The client is also the application of microservices . The client will configure the server URL Address , Once a call between services occurs , It will be configured in microservices Sleuth Monitor monitoring of , And generate the corresponding Trace and Span Send information to the server ( There are two main ways to send , One is HTTP Message mode , There is also a way of message bus, such as :RabbitMQ), Final ZipKin adopt UI The interface displays the data .

  • summary :Sleuth and Zipkin It's like Spring Boot Actuator and Spring Boot Admin The relationship between , One for generating data , One for displaying data .

6. Sleuth + Zipkin Implementation of distributed link tracking details ?

  • stay zuul The gateway implements a OncePerRequestFilter filter , Inject Zipkin Of Tracer take traceId and spanId Add to response header , It is convenient to view the interface call link
 String traceId = tracer.currentSpan().context().traceIdString();
 String spanId  = tracer.currentSpan().context().spanIdString();
 httpServletResponse.setHeader("traceId",traceId+","+spanId);
原网站

版权声明
本文为[weixin_ forty-three million seven hundred and sixty-six thousan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231525147911.html