技术标签: 学习 分布式系统 -- 追踪系统
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 支持追踪日志收集
文章浏览阅读1.8w次,点赞88次,收藏103次。整理 | 屠敏出品 | CSDN(ID:CSDNnews)在 2020 年初雪来临之际,TIOBE 官方在最新发布的 1 月编程语言榜单中为我们最终揭开了「 2019 年度编程语言」的神秘面纱,然意料之外情理之中,获此殊荣的并非是风风火火吵闹了一年又一年的 Python,而是一位低调的老兵——C 语言。Python 惜败,C成为 2019 年度编程语言曾几何时,凭借着“人生..._编程语言排行榜tiobe
文章浏览阅读1.1w次,点赞11次,收藏59次。Queue是RocketMQ中的另一个重要概念。在对该概念进行分析介绍前,我们先来看一张图:从本质上来说,RocketMQ中的Queue是数据分片的产物。为了更好地理解Queue的定义,我们还需要引入一个新的概念:Topic分片。在分布式数据库和分布式缓存领域,分片概念已经有了清晰的定义。同理,对于RocketMQ,一个Topic可以分布在各个Broker上,我们可以把一个Topic分布在一个Broker上的子集定义为一个Topic分片。对应上图,TopicA有3个Topic分片,分布在Broker
文章浏览阅读1.1w次。target ios版本和第三方库ios版本问题问题描述解决方法查看iphone iPad target的最低ios版本修改pod里第三方库问题描述这几天编辑xcode偶尔会发现这个错误,但是有时候重新编译一下错误就消失了,今天彻底解决一下这个错误错误提示:Compiling for iOS 10.0, but module ‘SwiftyJSON’ has a minimum deployment target of iOS 12.0: /Users/tdw/Library/Developer/Xc_compiling for ios 9.0, but module 'reactiveswift' has a minimum deployment t
文章浏览阅读2.8k次。Android NDK thread 回收crash, signal 4 (SIGILL), code 1 (ILL_ILLOPC) , fault addr 地址在NDK c++ 使用pthread_create 创建线程,不管是可分离线程还是非可分离的线程,在回收的时候都有这个问题,ndk-stack 定位到的问题行发现一切正常,卡了好几天,网上查了好久,看到了一篇帖子https://w...
文章浏览阅读1.9w次,点赞20次,收藏64次。 01:统计数字字符个数描述输入一行字符,统计出其中数字字符的个数。输入一行字符串,总长度不超过255。输出输出为1行,输出字符串里面数字字符的个数。样例输入Peking University is set up at 1898.样例输出4#include<bits/stdc++.h>using namespace std;in...
文章浏览阅读769次。Description轩神与奇牛是师徒,也是K友,经常打2K,可奇牛老是不故意放水让轩神输,于是轩神决定给奇 牛传授点人生经验以作补偿。 轩神拿出其珍藏多年的人生经验打造了n个经验球并连成一串,每一 个球里都含着一定量的人生经验。好玩的是,你打破一个球,你没法获得里面的人生经验,而只 能获得打破的那个球两边球的经验绝对值差。 假设轩神造了5个球,按顺序为 1 2 3 4 5 那么打破_轩神与奇牛是师徒,也是k友,经常打2k,可奇牛老是不故意放水让轩神输,于是轩神决定
文章浏览阅读39次。当服务实例很多时,都从配置中心读取文件,这时可以考虑将配置中心做成一个微服务,将其集群化,从而达到高可用,架构图如下:准备工作继续使用上一篇文章的工程,创建一个eureka-server工程,用作服务注册中心。在其pom.xml文件引入Eureka的起步依赖spring-cloud-starter-netflix- eureka-server,代码如下:<?xml version=...
文章浏览阅读3.5k次,点赞7次,收藏21次。对于c语言中"->"和"."的区别总结如下:1、A.B则A为对象或者结构体;2、A->B则A为指针,->是成员提取,A->B是提取A中的成员B,A只能是指向类、结构、联合的指针;3、(*a).b 等价于 a->b。"."一般情况下读作"的”; “->”一般读作"指向的结构体的"。也就是说在结构中,运算符->是运算符*和运算符.的结合4、“->”是指向..._->和.
文章浏览阅读2.1w次,点赞27次,收藏218次。ubuntu20.04安装ROS2_ubuntu20.04安装ros2
文章浏览阅读1.9k次,点赞3次,收藏16次。一、5G 基站能否智能“省电”?① 能耗和能效随着中国 5G 基站部署规模的扩大,5G 基站能耗惊人的说法甚嚣尘上,众口铄金,5G 基站似乎坐实“电老虎”的尴尬地位。如下是一张某运营商的内部流出照片,从中可以看出,5G AAU 和 4G RRU 的满载功耗相差极为悬殊,不得不承认 5G 的能耗确实远高于 4G:在移动的节能技术白皮书中,也明确地写着:“2019 年初 5G 基站功耗约为 4G 基站的 3~4 倍,高功耗是运营商大规模部署 5G 的棘手问题”:联通也在其白皮书中写道:“5
文章浏览阅读6k次。flyme8.1.5.0A系统精简内置软件包提示:精简系统有风险 在精简之前先备份资料 sdcard目录放置官网刷机包以备重新刷机在pc端用adb命令精简手机系统手机端打开usb调试模式 设置 ———关于手机————版本号 点击6~8次进入开发者模式设置————辅助功能————开发者选项————开启开发者选项 打开usb调试platform-tools下载地址https://developer.android.com/studio/releases/platfor_flyme8精简
文章浏览阅读366次。Traceback (most recent call last): File "E:/Pycharm Project/CTF/xman-ctf��¼.py", line 56, in <module> if accesss(urllib.unquote(sub_tables(i, w))): File "E:/Pycharm Project/CTF/xman-ctf��..._codefever盲注