sleuth+zipkin链路追踪

sleuth+zipkin链路追踪

build.gradle

plugins {
  id 'org.springframework.boot' version '2.6.11'
  id 'io.spring.dependency-management' version '1.0.11.RELEASE'
  id 'java'
  id 'maven'
}

group = 'com.emapgo'
archivesBaseName = 'feign-test'
version = '1.0.0'
sourceCompatibility = '1.8'

repositories {
    mavenLocal()
    maven {
        url "http://maven.aliyun.com/nexus/content/groups/public/"
    }
    mavenCentral()
}

dependencies {    
    
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.cloud:spring-cloud-starter-sleuth:3.1.5')
    compile('org.springframework.cloud:spring-cloud-sleuth-zipkin:3.1.5')
    compile('org.springframework.cloud:spring-cloud-starter-openfeign:3.1.5')
    compile('org.springframework.cloud:spring-cloud-loadbalancer:3.1.5')
    compile('com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config:2021.0.4.0')
    compile('com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:2021.0.4.0')
    compile('com.alibaba.cloud:spring-cloud-starter-alibaba-sentinel:2021.0.4.0')
    compile('com.alibaba.csp:sentinel-transport-simple-http:1.8.6')
    compile('com.alibaba.csp:sentinel-datasource-nacos:1.8.6')
  
}

看了很多资料都依赖的spring-cloud-starter-zipkin,结果版本各种不兼容,其实向zipkin发送信息依赖spring-cloud-sleuth-zipkin即可。
spring-cloud-starter-sleuth: 依赖该包即可打开链路追踪
spring-cloud-sleuth-zipkin: 该包负责向zipkin发送信息

application.yaml

server:
  port: 8081
spring:
  application:
    name: consumer
  main:
    allow-circular-references: true
  cloud:
    nacos:
      config:
        server-addr: 192.168.3.2:30848
        namespace: dev
      discovery:
        register-enabled: true
        server-addr: 192.168.3.2:30848
        namespace: dev
        group: test
        service: consumer
    sentinel:
      eager: true
      transport:
        port: 8719
        dashboard: 192.168.3.2:30880
      datasource:
        ds1:
          nacos:
            server-addr: 192.168.3.2:30848
            namespace: dev
            dataId: sentinel-rule
            groupId: test
            data-type: json
            rule-type: flow
  zipkin:
    base-url: http://192.168.3.2:30411
    sender:
      type: web
  sleuth:
    sampler:
      probability: 1.0
  config:
    import:
      - optional:nacos:hdmap4?group=test
feign:
  sentinel:
    enabled: true
    
logging.level.org.springframework.cloud.sleuth: DEBUG

zipkin.base-url: zipkin服务地址端口
zipkin.sender.type: 发送类型,除了web还有一些其他类型。如kafka等。
sleuth.sampler.probability: 0-1的数字,默认0.1。1代表所有请求都被追踪。
logging.level.org.springframework.cloud.sleuth: DEBUG 打开后可看到每次请求的traceId和spanId。

zipkin

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值