將Sleuth添加到項目裏做鏈路追蹤的三種方式(Greenwich.SR5版)

Important

To ensure that your application name is properly displayed in Zipkin, set the spring.application.name property in bootstrap.yml

方式一、Only Sleuth (log correlation)

方式二、Sleuth with Zipkin via HTTP通過Http方式收集追蹤數據

另外還需要配置yaml參數

spring.zipkin:
  base-url: http://localhost:9411
spring.sleuth:
  sampler:
    probability: 1.0

 方式三、Sleuth with Zipkin over RabbitMQ or Kafka 通過消息中間件收集追蹤數據

 配置yaml文件參數

#================rabbitmq====================    
spring.rabbitmq:
  host: 192.168.1.243
  virtual-host: /
  #與web訪問端口15672不一樣
  port: 5672
  username: rm_admin
  password: 12345678
#=================zipkin=====================
spring.zipkin:
  #base-url: http://localhost:9411
  sender:
   type: rabbit
  enable: true
#=================sleuth=====================
spring.sleuth:
  web:
    client:
      enabled: true
  sampler:
    #設置採樣比例,1.0表示100%,即全部都要;默認是0.1
    probability: 1.0
Sleuth微服務追蹤鏈路圖

官方文檔:https://cloud.spring.io/spring-cloud-static/Greenwich.SR5/multi/multi__introduction.html#_sleuth_with_zipkin_via_http

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章