sleuth

引入sleuth依赖

<dependency>    <groupId>org.springframework.cloud</groupId>    <artifactId>spring-cloud-starter-sleuth</artifactId></dependency>
#是否开启sleuth spring.sleuth.enabled=true

@ 展现成果

zpkin

增加zpkin依赖

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

配置

# 开启Sleuthspring.sleuth.enabled=true#指定zipkin server的地址,上报追踪日志spring.zipkin.base-url=http://localhost:9411# 采样率 越大采集率越高spring.sleuth.sampler.probability=1

启动zpkin-server

java -jar ipkin-server-2.12.9-exec.jar

如果要将数据存储到elasticsearch中

java -DSTORAGE_TYPE=elasticsearch -DES_HOSTS=http://localhost:9200 -jar zipkin-server-2.12.9-exec.jar

STORAGE_TYPE用于指定Zipkin的存储类型,这里为elasticsearch
ES_HOSTS 则用于指定Elasticsearch服务器地址列表,有多个节点时应用逗号分隔

如果存在elasticsearch,想查看依赖