Introduction and integration implementation of Zipkin

This article describes how to use Zipkin in spring Cloud projects. Kafka stores call link information in ElasticSearch, and you can view call link information in zipkin’s UI.

Core concepts and principles are introduced

traceId:

Only one traceId can be requested globally at a time. The number of requests used to find the same link in a flood of requests. For example, the servlet server receives the user request, invokes the Dubbo service, and then returns the result to the user. There is only one traceId in the whole link. It starts when the user requests it and ends when the user receives the result.

spanId:

There is one spanId for each request in a link. For example, each RPC, each SQL will have a separate spanId that is subordinate to traceId.

How Zipkin works

When a user makes a call, Zipkin’s client generates a globally unique Trace ID at the entry point for the entire call link and a SPAN ID for each distributed call within that link. Span can have parent-child nested relationships with span, representing upstream and downstream relationships in distributed calls. Span and span can be siblings, representing two child calls under the current call. A trace consists of a set of spans, which can be regarded as a tree with trace as the root node and SPAN as several child nodes.

Zipkin will trace the relevant information on the call link and asynchronously report the current call time information to Zipkin Server at the end of each call boundary. Zipkin Server stores the trace after it receives it. The Zipkin Web UI then extracts the trace information from storage through API access for analysis and display.

General flow chart

Implementation steps

Local installation and startup dependent middleware

  1. The RabbitMQ installation starts
  2. The ZooKeeper installation is started
  3. Kafka installation starts
  4. Elasticsearch installation started
  5. Zipkin-server installation started

Ii. Demo project integration and startup

The following configurations are integrated in the project:

	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter-zipkin</artifactId>
	</dependency>
Copy the code

Version used in the project:

SpringBoot: 2.1.4. RELEASE

SpringCloud: Greenwich.SR1

Startup steps:

  1. Start the eureka
  2. Start the waiter – service
  3. Start the barista – service
  4. Start the customer – service

Call zipkin UI

Visit zipkin: http://localhost:9411/zipkin/

The project address

Github.com/yclxiao/sc-…

Problems encountered

After using external storage, the UI of Zipkin cannot display the dependency information. The solution is to use zipkin-dependencies. Jar

  1. Download zipkin – dependencies. Jar, address: https://repo1.maven.org/maven2/io/zipkin/dependencies/zipkin-dependencies/2.3.2/,
  2. zipkin-dependenciesCreate jar file for elasticSearch; create jar file for ElasticSearch; create jar file for ElasticSearchSTORAGE_TYPE=elasticsearch ES_HOSTS=localhost:9200 java -jar zipkin-dependencies-2.3.2.jar
  3. You can also see the index of the new dependency in ElasticSearch

Resolve links:

Zinkin Advanced chapter – application of Zipkin-dependencies

Zipkin-dependencies global call chain generation

Refer to the link

Distributed – Zipkin + Springboot link tracking

Spring Cloud Combat Series (7) – Service Link Tracking Spring Cloud Sleuth

Spring Cloud Distributed Link Tracking Sleuth + Zipkin + Elasticsearch

Spring Cloud (12) : Distributed Link Tracking Sleuth and Zipkin

Zipkin – Microservice link tracking.

Use Spring Cloud Sleuth, Zipkin, Kafka, Elasticsearch to achieve distributed tracking

Zipkin integration with distributed call tracking system

SpringCloud (Finchley) integrates Sleuth, Zipkin, Kafka, ES