zipkin 官网
zipkin gitHub 仓库地址
zipkin server 配置信息 官方地址
code.7z
一、Introduce
1.1、brief introduce
Zipkin is a distributed tracing system. It helps gather timing data needed to troubleshoot latency problems in service architectures. Features include both the collection and lookup of this data.
大意如下:
Zipkin 是一个分布式追踪系统。它有助于收集计时数据,这些数据由于解决服务架构中的延迟问题。 Zipkin 提供了对收集来数据进行整理和整理之后的查找的功能。
1.2、Zipkin UI 界面
链路追踪图
If you have a trace ID in a log file, you can jump directly to it. Otherwise, you can query based on attributes such as service, operation name, tags and duration. Some interesting data will be summarized for you, such as the percentage of time spent in a service, and whether or not operations failed.
大意如下
通过
trace ID
, 服务,操作名称,标记,访问时长等可以进行链路的信息查询,链路信息上总结了如:本次请求花费总时间,各个服务节点间的时间花费及百分比,请求成功失败,甚至请求 URL ,请求方法等都能够进行展示。
服务依赖图
The Zipkin UI also presents a Dependency diagram showing how many traced requests went through each application. This can be helpful for identifying aggregate behavior including error paths or calls to deprecated service
大意如下
Zipkin 还提供了依赖关系图,用来显示每个应用程序中有多少跟踪请求。这有助于识别聚合行为,包括:错误路径或者不被推荐的服务调用。
二、Getting Started
使用 docker 启动,进行测试
Zipkin 提供的 Docker 案例
Docker Hub Zipkin 地址
2.1、Spring Cloud 链路测试代码
项目结构
项目依赖
访问 API http://localhost:28080/sleuth-client/hello?name=zhixing
zuul -> sleuth-client -> sleuth-server
2.2、Zipkin In Memory 部署
重启 zipkin 服务,之前收集的数据,失效。
step1、启动 docker 容器
docker run -d -p 9411:9411 --name zipkin-in-memory openzipkin/zipkin:2.12.9
step2、访问界面 http://ip:9411
step3、访问 API 查看请求链路信息
2.3、Zipkin In Mysql 部署
zipkin 收集到的数据持久化到 Mysql 中,重新内容仍存在
step1、启动 mysql 服务节点,并创建 zipkin
库,同时初始化脚本
docker run --name mysql_1 -p 3307:3306 -v ~/mysql_1/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d docker.io/mysql:5.7
step2、启动 zipkin 服务,指定 Mysql 信息
version: '2'
services:
zipkin:
image: openzipkin/zipkin:2.12.9
container_name: zipkin
environment:
- STORAGE_TYPE=mysql
- MYSQL_DB=zipkin
- MYSQL_USER=root
- MYSQL_PASS=123456
- MYSQL_HOST=192.168.2.154
- MYSQL_TCP_PORT=3307
ports:
- 9411:9411
启动
docker-compose up -d
step3、访问 API 查看请求链路信息(同上)
依赖如下图