当前位置:网站首页>Sleuth+Zipkin (visualization) service link tracking
Sleuth+Zipkin (visualization) service link tracking
2022-07-30 15:33:00 【Study hard and love you hard!】
为什么用
微服务架构是一个分布式架构,它按业务划分服务单元,一个分布式系统往往有很多个服务单元.由于服务单元数量众多,业务的复杂性,如果出现了错误和异常,很难去定位.主要体现在,一个请求可能需要调用很多个服务,而内部服务的调用复杂性,决定了问题难以定位.所以微服务架构中,必须实现分布式链路追踪,去跟进一个请求到底有哪些服务参与,参与的顺序又是怎样的,从而达到每个请求的步骤清晰可见,出了问题,很快定位.
链路追踪组件有 Google 的 Dapper,Twitter 的 Zipkin,以及阿里的 Eagleeye (鹰眼)等,它们都是非常优秀的链路追踪开源组件.
基本术语
- Span(跨度):基本工作单元,发送一个远程调度任务 就会产生一个 Span,Span 是一个 64 位 ID 唯一标识的,Trace 是用另一个 64 位 ID 唯一标识的,Span 还有其他数据信息,比如摘要、时间戳事件、Span 的 ID、以及进度 ID.
- Trace(跟踪):一系列 Span 组成的一个树状结构.请求一个微服务系统的 API 接口,这个 API 接口,需要调用多个微服务,调用每个微服务都会产生一个新的 Span,所有由这个请求产生的 Span 组成了这个 Trace.
- Annotation(标注):用来及时记录一个事件的,一些核心注解用来定义一个请求的开始和结束 .这些注解包括以下:
- cs - Client Sent -客户端发送一个请求,这个注解描述了这个 Span 的开始
- sr - Server Received -服务端获得请求并准备开始处理它,如果将其 sr 减去 cs 时间戳便可得到网络传输的时间.
- ss - Server Sent (服务端发送响应)–该注解表明请求处理的完成(当请求返回客户端),如果 ss 的时间戳减去 sr 时间戳,就可以得到服务器请求的时间.
- cr - Client Received (客户端接收响应)-此时 Span 的结束,如果 cr 的时间戳减去cs 时间戳便可以得到整个请求所消耗的时间.
整合Sleuth
pom
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
日志等级
logging:
level:
org.springframework.cloud.openfeign: debug
org.springframework.cloud.sleuth: debug
docker 安装zipkin
docker run -d -p 9411:9411 openzipkin/zipkin
整合zipkin
pom
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
application.yml
spring:
zipkin:
#地址
base-url: http://127.0.0.1:9411/
#关闭服务注册
discovery-client-enabled: false
#发送模式
sender:
type: web
#采样数据
sleuth:
sampler:
probability: 1
zipkin 数据持久化
通过docker 方式
docker run --env STORAGE_TYPE=elasticsearch --env ES_HOSTS=192.168.56.10:9200 openzipkin/zipkin-dependencies
作者声明
如有问题,欢迎指正!
边栏推荐
- 华为再发「天才少年」召集令!曾放弃360万年薪的他也来首秀
- Flink实时数仓完结
- [Cloud native] Grayscale release, blue-green release, rolling release, grayscale release explanation
- 被捧上天的Scrum敏捷管理为何不受大厂欢迎了?
- Configuration - Notes
- (Crypto essential dry goods) Detailed analysis of the current NFT trading markets
- 瑞吉外卖项目实战Day02
- QIIME2得到PICRUSt2结果后如何分析
- MySql error: SqlError(Unable to execute query", "Can't create/write to file OS errno 2 - No such file...
- Redis 缓存穿透、击穿、雪崩以及一致性问题
猜你喜欢
阿里CTO程立:阿里巴巴的开源历程、理念和实践
三电系统集成技术杂谈
Delayed message queue
JUC common thread pool source learning 02 ( ThreadPoolExecutor thread pool )
机房布线的至高境界,美到窒息
存储器映射、位带操作
瑞吉外卖项目实战Day02
去腾讯面试,直接让人出门左拐 :幂等性都不知道!
Flink实时仓库-DWS层(关键词搜索分析-自定义函数,窗口操作,FlinkSql设置水位线,保存数据到Clickhouse)模板代码
Redis cache penetration, breakdown, avalanche and consistency issues
随机推荐
Flink optimization
DDS Arbitrary Waveform Output Based on FPGA
QIIME2得到PICRUSt2结果后如何分析
websocket flv 客户端解封包
SEATA distributed transaction
Memory-mapped, bit-band operations
Redis cache penetration, breakdown, avalanche and consistency issues
Configuration - Notes
71页全域旅游综合整体解决方案2021 ppt
如何写一份高可读性的软件工程设计文档
1222. 可以攻击国王的皇后-力扣双百代码
CMake库搜索函数居然不搜索LD_LIBRARY_PATH
JHM:芳环羟化双加氧酶数据库DARHD建立及相关引物评价
Office Automation | Office Software and Edraw MindMaster Shortcuts
4位资深专家多年大厂经验分享出Flink技术内幕架构设计与实现原理
About the data synchronization delay of MySQL master-slave replication
B+树索引页大小是如何确定的?
The evolution of content products has three axes: traffic, technology, and product form
使用 protobuf 进行数据序列化
分布式前修课:MySQL实现分布式锁