zipkin Github地址
kafka请自行安装
1 zipkin-service zipkin服务
1.1 zipkin-service 加入以下依赖包
<dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-server</artifactId> </dependency> <dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-autoconfigure-ui</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-autoconfigure-collector-kafka</artifactId> <version>2.6.1</version> </dependency> <dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-autoconfigure-storage-mysql</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> </dependency>
1.2 ZipkinServiceApplication 加上注解
@EnableZipkinServer
1.3 application.yml 加入以下配置
spring: sleuth: enabled: false sampler: percentage: 1.0 datasource: name: zipkin type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/zipkin?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false username: root password: 123456 initialize: true continue-on-error: true zipkin: storage: type: mysql collector: kafka: zookeeper: localhost:2181zipkin mysql数据库脚本
2 test-service 测试服务
2.1 加入以下依赖包
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> <version>2.1.6.RELEASE</version> </dependency>
2.2 application.yml 加入以下配置
spring: zipkin: enabled: true sleuth: sampler: percentage: 1.0 kafka: bootstrap-servers: localhost:9092
end;