注册不到zipkin服务_31、Spring Cloud 中整合Zipkin进行服务跟踪zipkin-client

上一篇简介了Zipkin Server的搭建,但是从Spring boot 2.x版本后,Zipkin官网已经不再推荐自己搭建定制Zipkin,而是直接提供了编译好的jar包。详情可以查看官网:

https://zipkin.io/pages/quickstart.html

3aca45a5df8ec2634e54e86cebeed29c.png

有了Zipkin Server还不能对微服务的调用链路进行人祸监控,Zipkin Server可以被认为是一个数据处理和展示中心,那它的数据哪里来呢?需要Zipkin Client作为代理连接到Zipkin Server源源不断的上送过来。今天讲解一下如何在微服务中引入Zipkin Client,然后结合Zipkin Server监控各微服务间的调用链路。整体调用链路图如下:

41f9354d1a3357bff450e8a8d9802849.png

涉及的项目:

注册中心:sc-eureka-server

Zipkin server:sc-zipkin-server

微服务:sc-zipkin-client-web、sc-zipkin-client-service

1、新建项目sc-zipkin-client-service,对应的pom.xml文件如下

 4.0.0spring-cloud sc-zipkin-client-service 0.0.1-SNAPSHOTjarsc-zipkin-client-servicehttp://maven.apache.orgorg.springframework.boot spring-boot-starter-parent 2.0.4.RELEASEorg.springframework.cloud spring-cloud-dependencies Finchley.RELEASEpomimportUTF-81.81.8org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.cloud spring-cloud-starter-zipkin org.springframework.boot spring-boot-starter-web 

备注:主要引入了spring-cloud-starter-zipkin,说明这是一个zipkin client。

2、 新建配置文件application.yml

eureka: client: serviceUrl: defaultZone: http://localhost:5001/eureka/server: port: 9201spring: application: name: sc-zipkin-client-service zipkin: base-url: http://localhost:9000
aee41dc711fbceab4cde90453342f27f.png

3、sc-zipkin-client-service(普通的微服务)项目其他项目文件如下图

f72283eecba5c0a0ce4b0b1a6d5077f5.png

4、 新建项目sc-zipkin-client-web,对应的pom.xml文件如下

4.0.0spring-cloud sc-zipkin-client-web 0.0.1-SNAPSHOTjarsc-zipkin-client-webhttp://maven.apache.orgorg.springframework.boot spring-boot-starter-parent 2.0.4.RELEASEorg.springframework.cloud spring-cloud-dependencies Finchley.RELEASEpomimportUTF-81.81.8org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.cloud spring-cloud-starter-zipkin org.springframework.boot spring-boot-starter-web org.springframework.cloud spring-cloud-starter-openfeign 

备注:同样引入了spring-cloud-starter-zipkin,说明是一个zipkin client

5、 新建配置文件application.yml

 eureka: client: serviceUrl: defaultZone: http://localhost:5001/eureka/server: port: 9202spring: application: name: sc-zipkin-client-web zipkin: base-url: http://localhost:9000
b51ace06fb02cc7b3b61107cfa1b086e.png

6、sc-zipkin-client-web(普通的微服务)项目其他项目文件如下图

66f264f99122aa39b9ec1942f06ca656.png

7、 验证

项目启动顺序:

sc-eureka-server

sc-zipkin-server

sc-zipkin-client-service

sc-zipkin-client-web

访问注册中心:http://127.0.0.1:5001/

服务都已经注册成功

72f704b1ba67443c273de6bf735c7749.png

访问Zinkin Server:http://localhost:9000/zipkin/

e6268b882347b40e2d81340827ce64f2.png

目前zipkin server没有记录任何的微服务调用链路数据。

分别访问接口:

http://127.0.0.1:9202/user/listUser

dfd01175aab41c84cfb763856f48eb4e.png

http://127.0.0.1:9202/user/getUser/1

efa68cb2d390f55b60fc3dde0aa88972.png

再次查看Zipkin Server(如果没有出现可以多访问几次接口,Zipkin需要更多的监控数据)

5f4f294467320d71d739454197738c45.png
88522d46f502a51a088826a975824e0c.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值