初学zipkin搭建链路追踪服务注意事项
版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
</div>
<!--一个博主专栏付费入口-->
<!--一个博主专栏付费入口结束-->
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-833878f763.css">
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-833878f763.css">
<div class="htmledit_views" id="content_views">
<p><strong>1.zipkinserver的搭建</strong></p>
注意:因为关于 Zipkin 的服务端,在Spring Boot 2.x 版本后,官方就不推荐自行定制编译了(自行搭建方式在本文末补充),反而是直接提供了编译好的 jar 包来给我们使用(下载zipkin-server-xxx.jar ,使用JAVA命令启动该JAR,zipkin-server.jar是一个打包好的springBoot应用,springBoot自带tomcat因此只要启动JAR包就可以访问了。 java -jar zipkin-server-xxx.jar 启动完后访问localhost:9411可以查看统计界面)。还有其他两种方式搭建zipkinserver方式,详细情况参看
2.构件网关工程以及服务提供工程,这两个工程作为Zipkin 客户端, 需要将链路数据上传给Zipkin Server,同时它也作为 EurekaClient。
a.网关pom如下:
-
<dependencies>
-
-
<dependency>
-
-
<groupId>org.springframework.cloud</groupId>
-
-
<artifactId>spring-cloud-starter-zipkin</artifactId>
-
-
<version>1.2.1.RELEASE</version>
-
-
</dependency>
-
-
<dependency>
-
-
<groupId>org.springframework.cloud</groupId>
-
-
<artifactId>spring-cloud-starter-zuul</artifactId>
-
-
<version>1.4.4.RELEASE</version>
-
-
</dependency>
-
-
<dependency>
-
-
<groupId>org.springframework.boot</groupId>
-
-
<artifactId>spring-boot-starter-web</artifactId>
-
-
</dependency>
-
-
<dependency>
-
-
<groupId>org.springframework.cloud</groupId>
-
-
<artifactId>spring-cloud-starter-eureka</artifactId>
-
-
</dependency>
-
-
<dependency>
-
-
<groupId>org.springframework.boot</groupId>
-
-
<artifactId>spring-boot-starter-test</artifactId>
-
-
<scope>test</scope>
-
-
</dependency>
-
-
</dependencies>
b.网关的配置文件如下:
====================================
server.port=8768
spring.application.name=zipkinzuulclient
#指定 Zipkin Server 地址
spring.zipkin.base-url=http://localhost:9411
#通过配置这个参数来决定了日志记录发送给采集器的概率,0-1交给使用者自己配置。开发阶段和运行初期,
#一般配置成1全量收集日志,在默认情况下,该值为 0.1
spring.sleuth.sampler.percentage=1.0
#以下两个配置就可以将以"/sayhi/**"开头的 Url路由指定的url
zuul.routes.sayhi.path=/sayhi/**
zuul.routes.sayhi.url=http://localhost:1000
===================================
c.服务提供工程的pom如下:
-
<dependencies>
-
-
<dependency>
-
-
<groupId>org.springframework.cloud</groupId>
-
-
<artifactId>spring-cloud-starter-zipkin</artifactId>
-
-
<version>1.2.1.RELEASE</version>
-
-
</dependency>
-
-
<dependency>
-
-
<groupId>org.springframework.boot</groupId>
-
-
<artifactId>spring-boot-starter-web</artifactId>
-
-
</dependency>
-
-
<dependency>
-
-
<groupId>org.springframework.cloud</groupId>
-
-
<artifactId>spring-cloud-starter-eureka</artifactId>
-
-
</dependency>
-
-
<dependency>
-
-
<groupId>org.springframework.boot</groupId>
-
-
<artifactId>spring-boot-starter-test</artifactId>
-
-
<scope>test</scope>
-
-
</dependency>
-
-
</dependencies>
d.服务提供工程的配置
=====================================
spring.application.name=zipkinclient
server.port=1000
#设置服务注册中心的URL,本服务要向该服务注册中心注册自己
eureka.client.serviceUrl.defaultZone=http://ipa:8761/eureka
#指定 Zipkin Server 地址
spring.zipkin.base-url=http://localhost:9411
#通过配置这个参数来决定了日志记录发送给采集器的概率,0-1交给使用者自己配置。开发阶段和运行初期,
#一般配置成1全量收集日志,在默认情况下,该值 为 0.1
spring.sleuth.sampler.percentage=1.0
============================================
3.完整的项目搭建完毕,依次启动 eurekaserver、zipkinserver、zipkinzuulclient 和 zipkinclient。 在浏览器上访问http://localhost:8768/sayhi/GetTest/getTest, 浏览器显示:I am from :1000 再访问 http://localhost:9411 ,即访问 Zipkin 的展示界面,点击find traces可以看到对应的链路数据,例如请求的调用时间、消耗时间,以及请求调用的链路情况。(注意:需要先访问服务产生链路记录,才能在zipkin界面查到相应的servicename和spanname)
4.可以在链路中添加自定义数据,本案例在 zipkinzuulclient服务中新建一个过滤器,它的类型为 post 类型, order为0,开启拦截。在过滤器的拦截逻辑方法里, 通过 Tracer 的 addTag 方法在本案例中加上了链路的操作人,过滤器中部分代码如下:
-
@Autowired
-
-
Tracer tracer;//首先注入Tracer对象
-
-
@Override
-
-
public Object run() {
-
-
//在链路中添加链路操作人员记录
-
-
tracer.addTag("user", "lucus");
-
-
return null;
-
-
}
补充:在低版本中也可以自行创建zipkinserver工程,搭建zipkinserver服务,但是官方在2017年6月已经停止使用这种方式,并且要求链路追踪案例中所有案例工程(网关工程、服务提供工程)的搭建都是在低版本中进行,不能使用springboot 2.x,如:
springboot 1.5.9、
spring-cloud.version Dalston.SR1、
spring-cloud-starter-zipkin 1.2.1.RELEASE、
zipkin-server 1.27.0、
zipkin-autoconfigure-ui 1.27.0 等。
a.zipkinserver中引入pom依赖如下:
-
<dependencies>
-
<dependency>
-
<groupId>io.zipkin.java</groupId>
-
<artifactId>zipkin-server</artifactId>
-
<version>1.27.0</version>
-
</dependency>
-
<dependency>
-
<groupId>io.zipkin.java</groupId>
-
<artifactId>zipkin-autoconfigure-ui</artifactId>
-
<version>1.27.0</version>
-
</dependency>
-
-
<dependency>
-
<groupId>org.springframework.boot</groupId>
-
<artifactId>spring-boot-starter</artifactId>
-
</dependency>
-
<dependency>
-
<groupId>org.springframework.boot</groupId>
-
<artifactId>spring-boot-starter-web</artifactId>
-
</dependency>
-
<dependency>
-
<groupId>org.springframework.cloud</groupId>
-
<artifactId>spring-cloud-starter-eureka</artifactId>
-
<version>1.4.6.RELEASE</version>
-
</dependency>
-
-
<dependency>
-
<groupId>org.springframework.boot</groupId>
-
<artifactId>spring-boot-starter-test</artifactId>
-
<scope>test</scope>
-
</dependency>
-
</dependencies>
b.低版本中的zipkinserver的配置文件配置内容如下:
====================
#自定义端口号
server.port=9000
#设置服务注册中心的URL,本服务要向该服务注册中心注册自己
eureka.client.serviceUrl.defaultZone=http://ipa:8761/eureka
spring.application.name=zipkinserver
====================
c.启动类添加注释如下:
-
import org.springframework.boot.SpringApplication;
-
import org.springframework.boot.autoconfigure.SpringBootApplication;
-
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
-
-
import zipkin.server.EnableZipkinServer;
-
@EnableEurekaClient
-
@EnableZipkinServer
-
@SpringBootApplication
-
public class ZipkinServerApplication {
-
-
public static void main(String[] args) {
-
SpringApplication.run(ZipkinServerApplication.class, args);
-
}
-
}
原文地址:https://blog.csdn.net/fsy9595887/article/details/84936214
初学zipkin搭建链路追踪服务注意事项的更多相关文章
- spring cloud 2.x版本 Sleuth+Zipkin分布式链路追踪
前言 本文采用Spring cloud本文为2.1.8RELEASE,version=Greenwich.SR3 本文基于前两篇文章eureka-server.eureka-client.eureka ...
- zipkin分布式链路追踪系统
基于zipkin分布式链路追踪系统预研第一篇 分布式服务追踪系统起源于Google的论文“Dapper, a Large-Scale Distributed Systems Tracing Inf ...
- SpringCloud Sleuth + Zipkin 实现链路追踪
一.Sleuth介绍 为什么要使用微服务跟踪? 它解决了什么问题? 1.微服务的现状? 随着业务的发展,单体架构变为微服务架构,并且系统规模也变得越来越大,各微服务间的调用关系也变得越来越复杂 ...
- 原理分析dubbo分布式应用中使用zipkin做链路追踪
zipkin是什么 Zipkin是一款开源的分布式实时数据追踪系统(Distributed Tracking System),基于 Google Dapper的论文设计而来,由 Twitter 公司开 ...
- 原理分析dubbo分布式应用中使用zipkin做链路追踪(转)
作者:@nele本文为作者原创,转载请注明出处:https://www.cnblogs.com/nele/p/10171794.html 目录 zipkin是什么为什么使用Zipkinzipkin架构 ...
- 基于zipkin分布式链路追踪系统预研第一篇
本文为博主原创文章,未经博主允许不得转载. 分布式服务追踪系统起源于Google的论文“Dapper, a Large-Scale Distributed Systems Tracing Infras ...
- Zipkin客户端链路追踪源码解析
我们知道,Zipkin这个工具可以帮助我们收集分布式系统中各个系统之间的调用连关系,而且除了Servlet之外还能收集:MQ.线程池.WebSocket.Feign.Hystrix.RxJava.We ...
- Zipkin+Sleuth 链路追踪整合
1.Zipkin 是一个开放源代码分布式的跟踪系统 它可以帮助收集服务的时间数据,以解决微服务架构中的延迟问题,包括数据的收集.存储.查找和展现 每个服务向zipkin报告计时数据,zipkin会根据 ...
- 【zipkin】链路追踪
1,安装zipkin:https://zipkin.io/pages/quickstart.html 推荐使用docker去安装zipkin服务,下载安装执行都有了.缺点是下载要等待一段时间 2,使用 ...
随机推荐
- GoCN每日新闻(2019-11-09)
GoCN每日新闻(2019-11-09) 1. Go语言发行10周年庆祝 https://blog.golang.org/10years2. 容器中某Go服务GC停顿经常超过100ms排查 https ...
- Flutter之网络请求
Flutter之网络请求 一,介绍与需求 1.1,介绍 1,http一个可组合的,基于Future的库,用于发出HTTP请求.包含一组高级功能和类,可轻松使用HTTP资源.它与平台无关,可以在命令行和 ...
- navicat提示无法连接解决办法
1.错误如下图: 2.这个是由于mysql中user表中未设置允许该ip访问导致,解决办法: 1)查下user表:select user,host from user; 这张表就是mysql.user ...
- 东芝300D粉盒清零
东芝300D粉盒清零 1:打开前盖 2:按"OK"键3秒,等 显示 "更换硒鼓"(注:不用选 是/否,直接进入第3步) 3:按"启用"键 4 ...
- 如何查看电脑的GPU信息
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/qq_33690342/article/ ...
- 命令行利用ffmpeg实现rtmp推流《转》
ffmpeg在以前介绍过,是一个相当强大的工具,我们这次利用它实现rtmp推流(最终推流地址统一为rtmp://127.0.0.1:1935/live/123). 1.首先下载ffmpeg和ffpla ...
- js 计算总页数的最高效方式
js 计算总页数的最高效方式 /** * [getTotalPageNum 获取页码总数] * @param {[type]} totalRecord [总记录] * @param {[type]} ...
- 解决pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path问题
解决方案: 找到python的安装路径下的pytesseract: 例如我的是 C:\develop\Python\Lib\site-packages\pytesseract .用文本编辑器打开 ...
- 【452】pandas筛选出表中满足另一个表所有条件的数据
参考:pandas筛选出表中满足另一个表所有条件的数据 参考:pandas:匹配两个dataframe 使用 pd.merge 来实现 on 表示查询的 columns,如果都有 id,那么这是很好的 ...
- OpenShift 4.2 etcd operatorhub离线环境部署
本文记录在OperatorHub中存在界面但缺少镜像的环境下如何安装部署.感谢王征提供的大力支持和指导. 现在一个在线环境找到etcd所需要的镜像 quay.io/coreos/etcd-operat ...