

Spring Cloud之Finchley版学习(二十五)-Spring Cloud Sleuth与Zipkin配合使用
source link: https://www.wencst.com/archives/1658?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

一个良好的监控,应该有一个人类亲和的界面,这个界面就是Zipkin。本文详细讨论Sleuth如何与Zipkin配合使用。
Zipin简介
Zipkin是Twitter开源的分布式跟踪系统,基于Dapper的论文设计而来。它的主要功能是收集系统的时序数据,从而追踪微服务架构的系统延时等问题。Zipkin还提供了一个非常友好的界面,帮助我们分析追踪数据。
TIPS
Zipkin官方网站: http://zipkin.io/
Zipkin Server搭建
- 使用 https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=LATEST&c=exec 下载最新版本的Zipkin Server,例如
zipkin-server-2.11.3-exec.jar
- 启动Zipkin Server
java -jar zipkin-server-2.11.7-exec.jar
- 访问
http://localhost:9411
即可看到Zipkin Server的首页。
Zipkin UI
Zipkin UI首页:
简单讲解图中各个查询条件的含义:
① Service Name表示服务名称,也就是各个微服务spring.application.name的值。
② 第二列表示span的名称,“all”表示所有span,也可选择指定span。
③ Lookback用于执行想要查看的之间段。
④ Duration表示持续时间,即span从创建到关闭所经历的时间。
⑤ Limit表示查询几条数据。类似于MySQL数据库中的limit关键词。
⑥ Annotations Query,用于自定义查询条件。
微服务整合Zipkin
在 Spring Cloud之Finchley版学习(二十四)-Spring Cloud Sleuth入门 的基础上:
- 加依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-sleuth-zipkin</artifactId> </dependency>
- 加配置
spring: zipkin: base-url: http://localhost:9411 sleuth: sampler: # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。 probability: 1.0
测试
- 启动微服务,访问
http://localhost:8000/users/1
- 观察
http://localhost:9411
,可看到类似如下界面: - 点击上图中标注的3,可看到类似如下的界面:
如图,已经展示了该次请求的耗时。如果你有多个应用,Zipkin将会展示每个应用消耗了多少时间,蓝色表示请求正常,红色表示请求失败。
配套代码
Recommend
-
34
配置刷新三要素 spring-boot-starter-actuator /actuator/refresh management: endpoints: web: exposure: include: refresh 待刷新的配置属性所在的类上添加了 @Re...
-
30
经过前文讲述,我们的微服务架构日趋完善,已可使用Spring Cloud构建一个非常健壮的系统! 但假设,你的项目一旦出现问题,如何才能快速定位出来呢?一般项目上要求我们快速定位两种问题: 调用发生失败,快速定位...
-
68
分布式链路跟踪介绍 对于一个微服务系统,大多数来自外部的请求都会经过数个服务的互相调用,得到返回的结果,一旦结果回复较慢或者返回了不可用,我们就需要确定是哪个微服务出了问题。于是就有了分布式系统调用跟踪的诞生。
-
7
实现起来超简单的zipkin+sleuth微服务链路跟踪方案说是简单,tm那是找到解决方案之后才简单。可能是我用的SpringCloud版本太新了,自己配zipkin server把我给配吐了。又是版本冲突、又是注册不进去Eureka、又是访问ui报错、又是找不到Ob...
-
6
Spring Cloud Sleuth+zipkin实现链路追踪 Spring Cloud Sleuth 主要功能就是在分布式系统中提供追踪解决方案,并且兼容支持了 zipkin,你只需要在pom文件中引入相应的依赖即可。 微服务架构上通过业务来划分服务的,通...
-
4
SpringCloud系列教程(七)之使用Spring Cloud Sleuth+Zipkin实现链路追踪 August 06, 2021 8602 阅读提醒: 本文面向的是有一定springboot基础...
-
6
Spring Cloud Sleuth 和 Zipkin 进行分布式跟踪使用指南-51CTO.COM Spring Cloud Sleuth 和 Zipkin 进行分布式跟踪使用指南 作者:MicroStone 2022-02-18 09:30:48 分布式跟踪允许您跟踪分布式系统中的请求...
-
5
Distributed tracing with Zipkin and springcloud-sleuth Aug 6, 2017 Microservice architecture is a common architecture pattern that favors small services that’s independantly deployable which communicates with each other...
-
4
Part 6 : Distributed Tracing with Spring Cloud Sleuth and ZipkinSkip to content
-
7
链路追踪:Sleuth整合ZipKin-51CTO.COM
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK