【问题标题】:Disable distributed tracing for development禁用分布式跟踪以进行开发
【发布时间】:2019-10-24 18:53:54
【问题描述】:

我们正在搭建微服务框架。

我们使用以下堆栈进行分布式跟踪。

  • 弹簧靴
  • 卡夫卡
  • Zipkin

以下是配置的完成方式

gradle.build(或 pom.xml)中添加了以下启动器依赖项

compile 'org.springframework.cloud:spring-cloud-starter-sleuth'
compile 'org.springframework.cloud:spring-cloud-sleuth-zipkin'
compile 'org.springframework.cloud:spring-cloud-starter-bus-kafka'

添加一个 AlwaysSampler bean

@Bean
public Sampler defaultSampler() {
    return Sampler.ALWAYS_SAMPLE;
}

如果我们有 kafka 运行,事情会自动运行。

但是如果 kafka 没有运行,服务器不会启动 - 这主要是开发环境的情况。

如果我想停止这个,我必须注释掉这里提到的所有代码(因为我们在 spring boot 中使用 starter 依赖,它会按照我的理解自动配置)。

我们可以对属性(或 yaml)文件进行一些更改,这样我就不需要去注释掉所有这些代码了吗?

或者可能是另一种在不做评论等情况下禁用它的方法。

【问题讨论】:

    标签: spring-boot microservices spring-cloud-sleuth zipkin distributed-tracing


    【解决方案1】:

    您可以在属性键上添加以下设置以禁用 zipkin,source

    spring.zipkin.enabled=false
    

    更好的是,创建单独的开发属性(如application-dev.properties)以避免每次您想在机器上运行时更改上述设置:https://stackoverflow.com/a/34846351/4504053

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-20
      • 2019-12-24
      • 2020-06-11
      • 2018-05-19
      • 1970-01-01
      • 2013-04-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多