Spring Cloud Sleuth -- 调用链跟踪

Sleuth:[slu:θ],侦探

OpenTracing

官网:https://opentracing.io/
OpenTracing是CNCF 发布的分布式链路监控标准

Zipkin

官网:https://zipkin.io/
Sleuth 结合 Zipkin:Sleuth 发送日志给Zipkin,Zipkin 解析日志并展示结果

Spring Cloud Sleuth 项目构建

1、搭建Zipkin
2、配置Maven依赖

        
            org.springframework.cloud
            spring-cloud-starter-zipkin 
        

3、Spring Boot 配置

logging:
  level:
    org.springframework.web.servlet.DispatcherServlet: DEBUG    # 日志级别
spring.zipkin.base-url: http://localhost:9411/      # 指定zipkin地址
spring.sleuth.sampler.probability: 1   # 把日志sleuth日志100%发送给zipkin

4、访问 服务
5、查看Console日志

2018-12-12 16:29:57.047 DEBUG [Eureka-Client1,efde93b63083af9e,efde93b63083af9e,true] 7136 --- [nio-8060-exec-1] o.s.web.servlet.DispatcherServlet        : GET "/my/api3", parameters={}

2018-12-12 16:29:57.249 DEBUG [Eureka-Client1,efde93b63083af9e,efde93b63083af9e,true] 7136 --- [nio-8060-exec-1] o.s.web.servlet.DispatcherServlet        : Completed 200 OK

[]中的格式为 [服务名,traceID,spanID,是否发送给了分析工具]
6、查看Zipkin:http://localhost:9411/zipkin

你可能感兴趣的:(Spring Cloud Sleuth -- 调用链跟踪)