当前位置:网站首页>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
作者声明
如有问题,欢迎指正!
边栏推荐
- 去腾讯面试,直接让人出门左拐 :幂等性都不知道!
- InputStream和OutputStream流的使用
- Use of InputStream and OutputStream
- In-depth analysis of Kubernetes application management
- English语法_不定代词 - both / either / neither
- Huawei issues another summoning order for "Genius Boys"!He, who had given up an annual salary of 3.6 million, also made his debut
- [深入研究4G/5G/6G专题-46]: 5G Link Adaption链路自适应-2-常见缩略语
- 华为云重磅发布开源软件治理服务——软件成分分析
- GeoServer
- MongoDB启动报错 Process: 29784 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
猜你喜欢

组态 - 笔记

定时任务 corn

B+树索引页大小是如何确定的?

Alluxio为Presto赋能跨云的自助服务能力

Huawei issues another summoning order for "Genius Boys"!He, who had given up an annual salary of 3.6 million, also made his debut

瑞吉外卖项目实战Day02

MongoDB starts an error Process: 29784 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)

MongoDB启动报错 Process: 29784 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)

952. 按公因数计算最大组件大小 : 枚举质因数 + 并查集运用题

GeoServer + openlayers
随机推荐
存储器映射、位带操作
分布式限流 redission RRateLimiter 的使用及原理
微服务该如何拆分?
1700. 无法吃午餐的学生数量
自动化办公|办公软件和亿图脑图MindMaster快捷键
SEATA distributed transaction
本地事务与分布式事务
转换OTU表和序列文件为PICRUST2需要的格式
Redis cache penetration, breakdown, avalanche and consistency issues
我们公司用了 6 年的网关服务,动态路由、鉴权、限流等都有,稳的一批!
Flink real-time data warehouse completed
分布式前修课:MySQL实现分布式锁
Ts是什么?
The evolution of content products has three axes: traffic, technology, and product form
Huawei issues another summoning order for "Genius Boys"!He, who had given up an annual salary of 3.6 million, also made his debut
惊艳!京东T8纯手码的Redis核心原理手册,基础与源码齐下
定时任务 corn
5G-based Warehousing Informatization Solution 2022
Use of SLF4J
GeoServer + openlayers