前言:随着微服务系统的增加,服务之间的调用关系变得会非常复杂,这给运维以及排查问题带来了很大的麻烦,这时服务调用监控就显得非常重要了。spring cloud sleuth实现了对分布式服务的监控解决方案。

前情回顾请参考:

Spring Cloud 微服务一:Consul注册中心

Spring Cloud 微服务二:API网关spring cloud zuul

Spring Cloud 微服务三: API网关Spring cloud gateway

Spring Cloud 微服务四:熔断器Spring cloud hystrix

Spring Cloud 微服务五:Spring cloud gateway限流

  • 概览
  • Spring cloud sleuth实现了分布式系统的链路监控,用户可以通过可视化、交互式页面查看服务调用情况,并能够自动更关心服务调用状态

  • sleuth集成zipkin
    • 搭建zipkin服务,可以通过docker或者jar包的方式启动,具体可参考:https://github.com/openzipkin.本章主要使用spring的方式启动。首先新建一个module sleuth-server,在pom中引入以下依赖,版本我使用的与springboot 2.0.8.RELEASE相对应的2.11.7版本,该版本已经在父工程中定义。

       <artifactId>sleuth-server</artifactId>
      
          <dependencies>
      <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-zipkin</artifactId>
      </dependency>
      <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-server</artifactId>
      </dependency>
      <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-autoconfigure-ui</artifactId>
      </dependency>
      </dependencies>
    • 在启动类添加@EnableZipkinServer注解,表示该工程是一个服务器
      @SpringBootApplication
      @EnableZipkinServer
      public class SleuthServerApplication {
      public static void main(String[] args) {
      SpringApplication.run(SleuthServerApplication.class, args);
      }
      }
    • 配置application.yml,加入zipkin配置
      server:
      port: 9411 debug: true
      spring:
      application:
      name: sleuth-server
      management:
      metrics:
      web:
      server:
      auto-time-requests: false
    • 启动sleuth-server,访问http://localhost:9411进入主界面
    • 接下来配置user-consumer,在该工程的pom文件中添加zipkin依赖
      <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-zipkin</artifactId>
      </dependency>
    • application.yml中添加sleuth以及zipkin配置
        zipkin:
      base-url: http://localhost:9411/
      sleuth:
      sampler:
      probability: 1.0
    • 同样配置user-service
    • 启动user-service,user-consumer,访问服务,会在zipin页面上查询到。

最新文章

  1. 如何编写高效的jQuery代码
  2. Xml命名空间浅析
  3. 我是一只it小小鸟阅读笔记
  4. 【NOIP TG 解方程】
  5. 关于canvas 易忘属性
  6. swift论坛正式上线
  7. JS中的call()和apply()方法理解和使用
  8. java 内省
  9. kafka安装使用和遇到的坑
  10. .net core系列之《.net core内置IOC容器ServiceCollection》
  11. 再谈 tp的 实例化 类 的自动加载
  12. pyqt 不规则形状窗口显示
  13. [剑指Offer]50-第一个只出现一次的字符
  14. python3.3中print换行
  15. 如何使QLineEdit禁止编辑
  16. android 数据存储&amp;lt;一&amp;gt;----android短信发送器之文件的读写(手机+SD卡)
  17. MyEclipse持续性开发教程:用JPA和Spring管理数据(二)
  18. UVAlive5135_Mining Your Own Business
  19. Python列表练习题
  20. Yura

热门文章

  1. 【IntellJ IDEA】idea的Terminal窗口中文乱码 解决方法
  2. DBS:同学录
  3. python开发微信支付学习记录(转)
  4. 关于Docker&amp;kubernetes的一些问题
  5. java int转String全部方式的效率对照与深入解析
  6. win10企业版激活密钥
  7. [PWA] Cache Third Party Resources from a CDN in a React PWA
  8. 系统封装 如何修改别人的PE为己所用
  9. 雷锋沙龙 ppt 演讲内容分享(xss,流量劫持的利用)
  10. es6 - filter for-chrome