Table of contents
1. Import dependencies in the parent module
2. Add configuration in the module (note the level)
4. Start related services and open the postman calling interface
How can we see which of our microservices are running slowly or have problems?
Sentinel (real-time monitoring), nacos, of course, more detailed zipkin.
Zipkin is a distributed tracing system that can help locate problems and optimize the performance of microservices. You can see all links of time consumption, start and end time, and service calls.
The following is the specific usage:
1. Import dependencies in the parent module
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
2. Add configuration in the module ( note the level )
Add yml configuration in common (naming rule: application-xxx.yml):
spring:
# zipkin配置
zipkin:
base-url: http://127.0.0.1:9411 # zipkin服务地址
discovery-client-enabled: false # 禁止zipkin把自己当做nacos-client向nacos-server注册
# sleuth配置
sleuth:
sampler:
rate: 100 # sleuth抽样率默认是10%,设置为100表示100%请求上报zipkin
config:
name: config
In the module called by the business, refer to the common config
3. Start zipkin
Download link: Link: https://pan.baidu.com/s/1WRnR_blVaIF42qeCm1UgQw?pwd=4unb
Extraction code: 4unb
Start it with this command. Note that there should be no Chinese in the running directory.
java -jar zipkin-server-2.12.9-exec.jar
Start successfully, you can see the zipkin icon
4. Start related services and open the postman calling interface
What I use here is to place an order, and I need to add token in the Header
Five, zipkin interface
Error interface:
If the link is running in error, its color is red. You can see the total links and the execution time of each link.
Normal operation:
The color is blue.