ZipKin原理学习--ZipKin入门介绍
ZipKin入门介绍
Zipkin是一款开源的分布式实时数据追踪系统(Distributed Tracking System),基于 Google Dapper的论文设计而来,由 Twitter 公司开发贡献。其主要功能是聚集来自各个异构系统的实时监控数据。分布式跟踪系统还有其他比较成熟的实现,例如:Naver的Pinpoint、Apache的HTrace、阿里的鹰眼Tracing、京东的Hydra、新浪的Watchman,美团点评的CAT,skywalking等。
ZipKin架构
ZipKin可以分为两部分,一部分是zipkin server,用来作为数据的采集存储、数据分析与展示;zipkin client是zipkin基于不同的语言及框架封装的一些列客户端工具,这些工具完成了追踪数据的生成与上报功能,架构如下:
Zipkin Server主要包括四个模块:
(1)Collector 接收或收集各应用传输的数据
(2)Storage 存储接受或收集过来的数据,当前支持Memory,MySQL,Cassandra,ElasticSearch等,默认存储在内存中。
(3)API(Query) 负责查询Storage中存储的数据,提供简单的JSON API获取数据,主要提供给web UI使用
(4)Web 提供简单的web界面
服务追踪流程如下:
┌─────────────┐ ┌───────────────────────┐ ┌─────────────┐ ┌──────────────────┐
│ User Code │ │ Trace Instrumentation │ │ Http Client │ │ Zipkin Collector │
└─────────────┘ └───────────────────────┘ └─────────────┘ └──────────────────┘│ │ │ │┌─────────┐│ ──┤GET /foo ├─▶ │ ────┐ │ │└─────────┘ │ record tags│ │ ◀───┘ │ │────┐│ │ │ add trace headers │ │◀───┘│ │ ────┐ │ ││ record timestamp│ │ ◀───┘ │ │┌─────────────────┐│ │ ──┤GET /foo ├─▶ │ ││X-B3-TraceId: aa │ ────┐│ │ │X-B3-SpanId: 6b │ │ │ │└─────────────────┘ │ invoke│ │ │ │ request │││ │ │ │ │┌────────┐ ◀───┘│ │ ◀─────┤200 OK ├─────── │ │────┐ └────────┘│ │ │ record duration │ │┌────────┐ ◀───┘│ ◀──┤200 OK ├── │ │ │└────────┘ ┌────────────────────────────────┐│ │ ──┤ asynchronously report span ├────▶ ││ ││{ ││ "traceId": "aa", ││ "id": "6b", ││ "name": "get", ││ "timestamp": 1483945573944000,││ "duration": 386000, ││ "annotations": [ ││--snip-- │└────────────────────────────────┘
Instrumented client和server是分别使用了ZipKin Client的服务,Zipkin Client会根据配置将追踪数据发送到Zipkin Server中进行数据存储、分析和展示。
ZipKin几个概念
在追踪日志中,有几个基本概念spanId、traceId、parentId
traceId:用来确定一个追踪链的16字符长度的字符串,在某个追踪链中保持不变。
spanId:区域Id,在一个追踪链中spanId可能存在多个,每个spanId用于表明在某个服务中的身份,也是16字符长度的字符串。
parentId:在跨服务调用者的spanId会传递给被调用者,被调用者会将调用者的spanId作为自己的parentId,然后自己再生成spanId。
如下图:
刚发起调用时traceId和spanId是一致,parentId不存在。
被调用者的traceId和调用者的traceId时一致的,被调用者会产生自己的spanId,并且被调用者的parentId是调用者的spanId
安装
1、下载:
下载地址:https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=LATEST&c=exec
2、运行:java -jar zipkin-server-2.8.3-exec.jar
3、访问:zipkin Server 运行后默认的访问地址:http://localhost:9411
4、调用链分析
启动4个服务,调用关系如下:brave-webmvc-example服务调用brave-webmvc-example2,brave-webmvc-example2分别调用brave-webmvc-example3和brave-webmvc-example4(代码地址),链路关系如下图:
右上角JSON节目可以看到4个服务的调用数据如下图:
[{"traceId": "a4aa11d855699355","id": "a4aa11d855699355","name": "get /start","timestamp": 1526110753393795,"duration": 3873359,"annotations": [{"timestamp": 1526110753393795,"value": "sr","endpoint": {"serviceName": "brave-webmvc-example","ipv4": "192.168.1.101"}},{"timestamp": 1526110757267154,"value": "ss","endpoint": {"serviceName": "brave-webmvc-example","ipv4": "192.168.1.101"}}],"binaryAnnotations": [{"key": "ca","value": true,"endpoint": {"serviceName": "","ipv6": "::1","port": 64570}},{"key": "http.method","value": "GET","endpoint": {"serviceName": "brave-webmvc-example","ipv4": "192.168.1.101"}},{"key": "http.path","value": "/start","endpoint": {"serviceName": "brave-webmvc-example","ipv4": "192.168.1.101"}},{"key": "mvc.controller.class","value": "HomeController","endpoint": {"serviceName": "brave-webmvc-example","ipv4": "192.168.1.101"}},{"key": "mvc.controller.method","value": "start","endpoint": {"serviceName": "brave-webmvc-example","ipv4": "192.168.1.101"}}]},{"traceId": "a4aa11d855699355","id": "cf49951d471ac7c5","name": "get /foo","parentId": "a4aa11d855699355","timestamp": 1526110753583404,"duration": 3650640,"annotations": [{"timestamp": 1526110753583404,"value": "cs","endpoint": {"serviceName": "brave-webmvc-example","ipv4": "192.168.1.101"}},{"timestamp": 1526110754327066,"value": "sr","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}},{"timestamp": 1526110757234044,"value": "cr","endpoint": {"serviceName": "brave-webmvc-example","ipv4": "192.168.1.101"}},{"timestamp": 1526110757235819,"value": "ss","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}}],"binaryAnnotations": [{"key": "ca","value": true,"endpoint": {"serviceName": "","ipv4": "127.0.0.1","port": 64578}},{"key": "http.method","value": "GET","endpoint": {"serviceName": "brave-webmvc-example","ipv4": "192.168.1.101"}},{"key": "http.method","value": "GET","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}},{"key": "http.path","value": "/foo","endpoint": {"serviceName": "brave-webmvc-example","ipv4": "192.168.1.101"}},{"key": "http.path","value": "/foo","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}},{"key": "mvc.controller.class","value": "HomeController","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}},{"key": "mvc.controller.method","value": "foo","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}}]},{"traceId": "a4aa11d855699355","id": "c2c029d693ecc49b","name": "get /bar","parentId": "cf49951d471ac7c5","timestamp": 1526110754397322,"duration": 1583187,"annotations": [{"timestamp": 1526110754397322,"value": "cs","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}},{"timestamp": 1526110755367168,"value": "sr","endpoint": {"serviceName": "brave-webmvc-example3","ipv4": "192.168.1.101"}},{"timestamp": 1526110755810759,"value": "ss","endpoint": {"serviceName": "brave-webmvc-example3","ipv4": "192.168.1.101"}},{"timestamp": 1526110755980509,"value": "cr","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}}],"binaryAnnotations": [{"key": "ca","value": true,"endpoint": {"serviceName": "","ipv4": "127.0.0.1","port": 64583}},{"key": "http.method","value": "GET","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}},{"key": "http.method","value": "GET","endpoint": {"serviceName": "brave-webmvc-example3","ipv4": "192.168.1.101"}},{"key": "http.path","value": "/bar","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}},{"key": "http.path","value": "/bar","endpoint": {"serviceName": "brave-webmvc-example3","ipv4": "192.168.1.101"}},{"key": "mvc.controller.class","value": "HomeController","endpoint": {"serviceName": "brave-webmvc-example3","ipv4": "192.168.1.101"}},{"key": "mvc.controller.method","value": "bar","endpoint": {"serviceName": "brave-webmvc-example3","ipv4": "192.168.1.101"}}]},{"traceId": "a4aa11d855699355","id": "e3968cec8747ce95","name": "get /tar","parentId": "cf49951d471ac7c5","timestamp": 1526110756017988,"duration": 1194871,"annotations": [{"timestamp": 1526110756017988,"value": "cs","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}},{"timestamp": 1526110757081683,"value": "sr","endpoint": {"serviceName": "brave-webmvc-example4","ipv4": "192.168.1.101"}},{"timestamp": 1526110757212859,"value": "cr","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}},{"timestamp": 1526110757222145,"value": "ss","endpoint": {"serviceName": "brave-webmvc-example4","ipv4": "192.168.1.101"}}],"binaryAnnotations": [{"key": "ca","value": true,"endpoint": {"serviceName": "","ipv4": "127.0.0.1","port": 64584}},{"key": "http.method","value": "GET","endpoint": {"serviceName": "brave-webmvc-example4","ipv4": "192.168.1.101"}},{"key": "http.method","value": "GET","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}},{"key": "http.path","value": "/tar","endpoint": {"serviceName": "brave-webmvc-example4","ipv4": "192.168.1.101"}},{"key": "http.path","value": "/tar","endpoint": {"serviceName": "brave-webmvc-example2","ipv4": "192.168.1.101"}},{"key": "mvc.controller.class","value": "HomeController","endpoint": {"serviceName": "brave-webmvc-example4","ipv4": "192.168.1.101"}},{"key": "mvc.controller.method","value": "tar","endpoint": {"serviceName": "brave-webmvc-example4","ipv4": "192.168.1.101"}}]}
]
5、zipkin client采集
目前官方提供了如下客户端插件进行追踪数据的采集(https://github.com/openzipkin/brave/tree/master/instrumentation)
题外话:由于项目需要和本人推动,尝试,官方在 2.15 版本添加支持 ActiveMQ 支持追踪日志收集
ZipKin原理学习--ZipKin入门介绍相关推荐
- java 父子线程 调用链_ZipKin原理学习--Zipkin多线程及线程池中追踪一致性问题解决...
在学习Zipkin分布式追踪系统中我们了解到Trace在整个调用链是一致的,在web服务中可以通过在header设置Trace值在不同的服务中进行传递,那样在一个服务内部不同的线程,甚至是线程池中Zi ...
- ZipKin原理学习(分布式实时数据追踪系统)+window部署zipkin+k8s部署zipkin
全栈工程师开发手册 (作者:栾鹏) 架构系列文章 ZipKin入门介绍 Zipkin是一款开源的分布式实时数据追踪系统(Distributed Tracking System),基于 Google D ...
- 一阶系统开环传递函数表达式_自控原理之系统辨识--入门介绍
写在最前: 你在调PID的时候,肯定也想过,有没有一些科学有用的方法,可以调出准确的PID参数,而不是花很多时间瞎调. 如果你想知道系统辨识能做什么,可以看我之前写过的文章,通过系统辨识出传递函数,来 ...
- 深度学习简介--入门介绍PPT
背景介绍 以下深度学习PPT内容为在 测试组 分享的内容. PPT为自己制作,图片来源于网络(其他博客或文章中),部分蓝色的内容为使用MATLAB的深度学习的电子书内容 MATLAB 深度学习简介电子 ...
- openGL学习之入门介绍
最近项目中涉及到了一些特效,如字体描边.场景调色和精灵的一些着色等,接触到了openGl部分,再加上之前有过unity3d的开发经验,就越发的对openGl感兴趣,应该说是对3D感兴趣吧.其实自己一直 ...
- python怎么启动mne_mne-python学习之一 入门介绍
mne-python脑电图和肌电图是一个开源软件分析.处理和显示.遵循bsd许可协议,由哈佛大学和共同开发的社区.主要功能包括:预处理和脑电图\/梅格信号的去噪,源估计.时频分析.统计测试,功能连接, ...
- 独家 | 集成学习入门介绍
作者:Jason Brownlee 翻译:wwl 校对:王琦 本文约3300字,建议阅读8分钟. 本文介绍了我们在生活中的许多决定包括了其他人的意见,由于群体的智慧,有的时候群体的决策优于个体.在机器 ...
- 干货 :集成学习入门介绍
作者:Jason Brownlee 翻译:wwl 校对:王琦 本文约3300字,建议阅读8分钟. 本文介绍了我们在生活中的许多决定包括了其他人的意见,由于群体的智慧,有的时候群体的决策优于个 ...
- 吴恩达《深度学习》课程介绍
吴恩达<深度学习>(Andrew Ng <Deep Learning>)专业课程主要有五门课组成: 1.神经网络和深度学习(Neural Networks and Deep L ...
最新文章
- 聊聊linux查看服务和端口状态命令netstat
- 使用Vue动态生成form表单的实例代码
- 软件评测-信息安全-应用安全-资源控制-用户登录限制(中)
- OpenGL教程——GLUT初始化
- 内存管理中的几种地址类型
- 《Java8实战》笔记(16):结论以及Java的未来
- 数据库高级知识——索引优化分析(一)
- Pure公司发布机架规模FlashBlade对象与文件存储方案
- Hololens开发入门篇-郑洪智-专题视频课程
- hbuilder调试代码_【移动端】hbuilder创建app并利用真机运行调试
- 前端那些事之日历多选插件篇
- 图新地球点云大师:点云数据三维可视化管理及等高线提取
- Ubuntu安装中文字体
- Crawlscrapy获取果壳问答信息
- 合天实验室:渗透测试项目一
- Unity3D 工程机械以及常见机构铰链,关节绑定 插件
- vue中使用element-tiptap
- 半波、全波和全桥整流
- 简述PGA相关概念及参数
- profile master 2000 CAM-DUCT_v2.26.050 风管展开软体\
热门文章
- ChatGPT真神奇,但是也真焦虑
- Spring源码剖析-单利Bean的实例化(六)
- Apache Pulsar在智联招聘的实践 -- 从消息队列到基于Apache Pulsar的事件中心
- linux创建用户只读权限
- 智慧职教Revit建模技术(第一次开课答案)(课程负责人:刘佳老师)
- 自己购买的域名如何设置子域名,如何设置访问多个项目,万网域名如何设置显性url转发和隐性URL转发,以及如何通过github 转发到自己的地址
- 用java实现停车场管理系统
- 半年总结(二)---2015
- 从Windows走入Docker(四)如何使用Docker Desktop的快速5步教程
- 这个春节,我一直在牵挂一个人