1.上一编我们已经学习gateway网关统一入口了,这编我们整合sleuth+zipkin,链路追踪,方便我们快速知道一个请求的所有调用链。
2.在我们的cloud-user和cloud-product 的pom.xml 引入
<!--链路追踪 Sleuth--> <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>
这两个的依赖包
两个配置文件都增加一下的配置
zipkin: base-url: http://localhost:9411 discovery-client-enabled: false sleuth: sampler: percentage: 1.0
最后结果类似:
spring: cloud: nacos: discovery: server-addr: localhost:8848 config: server-addr: localhost:8848 file-extension: yaml #sentinel: #transport: #dashboard: localhost:8080 #port: 8719 application: name: use