附8 zipkin
Zipkin
2023-09-27 14:22:34 时间
一、zipkin作用
- 全链路追踪工具(查看依赖关系)
- 查看每个接口、每个service的执行速度(定位问题发生点或者寻找性能瓶颈)
二、zipkin工作原理
- 创造一些追踪标识符(tracingId,spanId,parentId),最终将一个request的流程树构建出来
三、zipkin架构
1、Transport
- transport作用:收集被trace的services的spans,并将它们转化为zipkin common Span,之后把这些Spans传递的存储层。
- 三种主要的transport:
- HTTP(默认)
- 通过http headers来传递追踪信息
- header中的key
- X-B3-TraceId: 64 encoded bits(id被encode为hex Strings)
- X-B3-SpanId: 64 encoded bits
- X-B3-ParentSpanId: 64 encoded bits
- X-B3-Sampled: Boolean (either “1” or “0”)(下面的调用是否进行采样)
- X-B3-Flags: a Long
- Scribe
- Kafka
- HTTP(默认)
2、基础架构(4个组件)
- collector
- 作用:zipkin collector会对一个到来的被trace的数据(span)进行验证、存储并设置索引。
- storage
- search
- webUI
四、zipkin核心数据结构
- Annotation(用途:用于定位一个request的开始和结束,cs/sr/ss/cr含有额外的信息,比如说时间点)
- cs:Client Start - This sets the beginning of the span
- 一个span的开始
- sr:Server Receive - The server has received the request and will start processing it
- ss:Server Send - The server has completed processing and has sent the request back to the client
- cr:Client Receive - The client has received the response from the server. This sets the end of the span. The RPC is considered complete when this annotation is recorded
- 一个span的结束
- 当这个annotation被记录了,这个RPC也被认为完成了
- cs:Client Start - This sets the beginning of the span
- BinaryAnnotation(用途:They are meant to provide extra information about the RPC)
- Span:就是一个请求(包含一组Annotation和BinaryAnnotation)
- Spans contain identifying information such as traceId, spandId, parentId, and RPC name
- Trace:
- Traces are built by collecting all Spans that share a traceId
- 通过traceId、spanId和parentId,被收集到的span会汇聚成一个tree,从而提供出一个request的整体流程。(这也是zipkin的工作原理)
注意:时间点计算
- sr-cs:网络延迟
- ss-sr:逻辑处理时间
- cr-cs:整个流程时间
五、Trace identifiers
- 含义:通过下边3个Id,对数据进行重组
- 三个Id(64位 long型数据)
- TraceId
- The overall ID of the trace.
- Every span in a trace will share this ID.
- SpanId
- The ID for a particular span.
- This may or may not be the same as the trace id.
- ParentId
- This is an optional ID that will only be present on child spans.
- That is the span without a parent id is considered the root of the trace.
- TraceId
六:zipkin工作流程图
说明:
- X和A可以相等
疑问:
- spanId==C的span为什要有,是否可以省掉?
父子span关系:
说明:parentId==null,表示该span就是root span。
七、注意点
1、使用zipkin,必须使用java8
2、在生产环境,不会对每个请求都进行采样追踪(降低trace对整个服务的性能损耗)
参考:
https://github.com/openzipkin/zipkin/tree/master/zipkin-server server配置
相关文章
- 开发架构系列1-什么是 Nacos、Zipkin、工单、ZooKeeper、xxl-job、jenkins、 JSP、Servlet、EFK、Grafana、RDP、eclipse、ProM
- Nacos、ZipKin、Prometheus
- SpringCloud Sleuth+Zipkin 分布式链路追踪
- SpringCloud微服务(07):Zipkin组件,实现请求链路追踪
- 微服务技术系列教程(43)- SpringCloud -Zipkin环境集成
- 微服务技术系列教程(42)- SpringCloud -Sleuth与Zipkin服务链路
- spring-cloud-sleuth+zipkin追踪服务实现(一)
- spring-cloud-sleuth+zipkin追踪服务实现(二)
- 行为链分析zipkin
- 微服务—链路追踪(Sleuth+Zipkin)
- Zipkin整合rabbitmq和mysql
- Zipkin进行数据存储的时候查询出问题
- SpringCloud之整合Zipkin+Sleuth(十四)
- SpringCloud Zipkin
- Spring cloud Zipkin 链路追踪安装配置和使用,SpringCloud Zipkin server 下载安装
- 分布式追踪系统sleauth+zipkin
- 一、zipkin
- Spring Cloud sleuth with zipkin over RabbitMQ教程
- 手把手学习springcloudalibaba:集成链路追踪sleuth+zipkin实战总结
- 链路追踪Zipkin整合
- 配合 envoy 使用 Zipkin
- spring cloud zipkin sleuth与spring boot aop结合后,启动慢
- 微服务架构之链路追踪Sleuth+Zipkin