微服务直接调用组件sleuth

1、定位微服务出错。

2、定位微服务性能问题。

调用链监控原理

trace表,cs client sent ,sr server recieve,ss server sent,cr client recieve

id span_id pspan_id service_name api stage timestamp
1 uuid1 null content-center /shares/1 cs t1
2 uuid2 uuid1 user-center /user/1 sr t2
3 uuid2 uuid1 user-center /user/1 ss t3
4 uuid3 null content-center /shares/1 cr t4

3、Spring Cloud Sleuth +ZipKin

Skywalking,Pinpoint

4、整合sleuth

1)什么是sleuth

spring cloud 分布式跟踪解决方案,产生监控数据

2)术语

span上面数据库中的一条记录

trace 就是一组跟踪数据

3)整合sleuth

一加依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>

4)整合数据库和管理界面zipkin

详情见https://www.imooc.com/article/291572

 <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>

加配置启动管理界面

zipkin:
  base-url: http://localhost:9411/
sleuth:
  sampler:
    #抽样率
    probability: 1.0

5)整合后nacos报错,详情参见https://www.imooc.com/article/291578

Spring Cloud将http://localhost:9411当作了服务发现里面的微服务名称,但是实际没有注册服务。

一、正确识别url

zipkin:
    base-url: http://localhost:9411/
    #bug 导致
    discoveryClientEnabled: false
  sleuth:
    sampler:
      #抽样率
      probability: 1.0

二、将zipkin注册到nacos(实际不可行)

6)zipkin数据持久化

mysql 性能问题

es

cassandra

启动STORAGE_TYPE=elasticsearch ES_HOSTS=localhost:9200 java -jar zipkin-server-2.12.9-exec.jar

7)依赖关系图

https://www.github.com/openzipkin/zipkin-dependencies

猜你喜欢

转载自www.cnblogs.com/xiaofeiyang/p/12393728.html