Construction and use of SpringCloud-zipkin microservice link tracking

For the project address, please go to gitee to download and view https://gitee.com/xwb1056481167/spring-cloud

Zipkin

Zipkin is an open source distributed real-time data tracking system (Distributed Tracking System), designed based on Google Dapper's papers and developed and contributed by Twitter. Its main function is to gather real-time monitoring data from various heterogeneous systems. There are other mature implementations of the distributed tracking system, such as: Naver's Pinpoint, Apache's HTrace, Ali's Hawkeye Tracing, JD's Hydra, Sina's Watchman, Meituan Dianping's CAT, skywalking, etc.

zipkin-server download

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

After downloading, it needs to be executed in the directory where it is located

java -jar zipkin-server-2.12.9-exec.jar

Enter the browser and enter:  http://localhost:9411/

Official working principle diagram

Schematic after abstraction

Link monitoring

service provider

Operation project cloud-provider-payment8001 

1. Add zipkin to pom.xml

<!-- 引入sleuth+zipkin -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>

Why is zipkin only introduced but not sleuth (because zipkin already includes sleuth)

2, yml added zipkin placement

spring:
  zipkin:
    base-url: http://localhost:9411 #监控的数据放到改地址下供监控使用
  sleuth:
    sampler:
      #采样率 值介于0到1之间,1表示全部采样
      probability: 1

3. The controller adds a call link to provide release

@GetMapping("/payment/zipkin")
public String paymentZipkin() {
    return "hi,i'am paymentZipkin server fall back, welcome to";
}

Service consumer (caller) cloud-consumer-order80


1 、 pom.xml

<!-- 引入sleuth+zipkin -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>

2 、l

spring:
  zipkin:
    base-url: http://localhost:9411 #监控的数据放到改地址下供监控使用
  sleuth:
    sampler:
      #采样率 值介于0到1之间,1表示全部采样
      probability: 1

3、controller

@GetMapping("/consumer/payment/zipkin")
public String getPayment2() {
    String result = restTemplate.getForObject("http://localhost:8001/payment/zipkin", String.class);
    return result;
}

test

Start 7001, 8001, 80 and send  http://localhost/consumer/payment/zipkin request to view

 

Guess you like

Origin blog.csdn.net/www1056481167/article/details/113600898