SpanID : 阶段性 ID,比如一次 RPC 有可能多 Span
TraceID:一次 RPC 只有一个 TraceID
<!-- 整合 Spring Cloud Sleuth -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<!-- Zipkin Server 整合 -->
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
</dependency>
<!-- Zipkin Server UI 整合 -->
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
</dependency>
HTTP 方式采集
package com.springcloud.lesson15.zipkin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import zipkin2.server.internal.EnableZipkinServer;
/**
* TODO
*
* @author <a href="mailto:[email protected]">Finen</a>
* @see
* @since
*/
@SpringBootApplication
@EnableZipkinServer
public class ZipkinServerApplication {
public static void main(String[] args) {
SpringApplication.run(ZipkinServerApplication.class, args);
}
}
## 应用元信息
## 配置服务器应用名称
spring.application.name = zipkin-server
## 配置服务器端口
server.port = 20000
# 启用端点 env
management.endpoint.env.enabled=true
# 暴露端点 env 配置多个,隔开
management.endpoints.web.exposure.include=*
HTTP 方式上报
<!-- 整合 Spring Cloud Zipkin -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
## Zipkin 配置
### 配置 Zipkin 服务器
zipkin.server.host = localhost
zipkin.server.port = 20000
spring.zipkin.base-url = http://${zipkin.server.host}:${zipkin.server.port}
<!-- 整合 Spring Cloud Zipkin -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
## Zipkin 配置
### 配置 Zipkin 服务器
zipkin.server.host = localhost
zipkin.server.port = 20000
spring.zipkin.base-url = http://${zipkin.server.host}:${zipkin.server.port}
<!-- zipkin 整合 Spring Cloud Sleuth Stream -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<!-- 整合 Spring Cloud Stream Binder Rabbit MQ -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
Stream 方式采集
package com.segumentfault.spring.cloud.lesson15.zipkin.server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.sleuth.zipkin.stream.EnableZipkinStreamServer;
/**
* Zipkin 服务器应用
*
* @author <a href="mailto:[email protected]">Mercy</a>
* @since 0.0.1
*/
@SpringBootApplication
//@EnableZipkinServer
@EnableZipkinStreamServer
public class ZipkinServerApplication {
public static void main(String[] args) {
SpringApplication.run(ZipkinServerApplication.class, args);
}
}
Stream 方式上报
<!-- 整合 Spring Cloud Sleuth -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<!-- 整合 Spring Cloud Sleuth Stream -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-stream</artifactId>
</dependency>
<!-- 整合 Spring Cloud Stream Binder Rabbit MQ -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
注意应移除
spring-cloud-starter-zipkin
依赖
Stream 方式上报
<!-- 整合 Spring Cloud Sleuth -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<!-- 整合 Spring Cloud Sleuth Stream -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-stream</artifactId>
</dependency>
<!-- 整合 Spring Cloud Stream Binder Rabbit MQ -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
注意应移除
spring-cloud-starter-zipkin
依赖