1. An overview of the

1.1 Why did this technology emerge? What problems need to be solved?

In the frame of the micro service, launched a client request to the backend system passes through a number of different service node in the call to collaborate last request as a result, every paragraph requests to 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.

Solve what problem?


Suppose that now the product transfer inventory module, after sending the link data, who transfers who Zipkin will record, in the form of web page display

1.2 what is

https://github.com/spring-cloud/spring-cloud-sleuth Spring Cloud Sleuth provides a complete set of service tracking solution In a distributed system with tracking solutions and compatible support zipkin

2. Set up the link monitoring procedure

2.1 zipkin download

2.1.1 SpringCloud does not need to build Zipkin Server by itself since version F, only needs to call the JAR package
2.1.2 download address: https://dl.bintray.com/openzipkin/maven/io/zipkin/java/zipkin-server/
2.1.3 Run jar java-jar zipkin-server-2.12.9-exec.jar
2.1.4 Running the console

http://localhost:9411/zipkin/ complete the invocation of the link


The picture above shows


Noun explanation

  • 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

2.2 Service Providers

2.2.1 modify cloud provider – payment8001

Pom files add zipkin dependencies

<! -- sleuth+zipkin-->

<dependency>

    <groupId>org.springframework.cloud</groupId>

    <artifactId>spring-cloud-starter-zipkin</artifactId>

</dependency>

Copy the code

Yml file adds zipkin configuration

spring:

  application:

    name: cloud-payment-service

  zipkin:

    base-url: http://localhost:9411

  sleuth:

    sampler:

      probability: 1# The sampling rate is between0to1Between,1Indicates all collection

Copy the code

Add the following code to PaymentController

@GetMapping("/payment/zipkin")

public String paymentZipkin(a){

    return "hi I am paymentzipkin server fallback, welcome to beijing";

}

Copy the code

2.3 Service Consumers

Add the following code to the POM file to add zipkin to the YML file to configure OrderController

//====================>zipkin+sleuth

@GetMapping("/consumer/payment/zipkin")

public String paymentZipkin(a){

    String result = restTemplate.getForObject("http://localhost:8001"+"/payment/zipkin", String.class);

    return result;

}

Copy the code

2.4 Start Eureka7001/8001/80 in sequence

Call 80 8001 http://localhost/consumer/payment/zipkin several times

2.5 Opening a Browser

http://localhost:9411 The following screen is displayed


To view


Viewing dependencies