【问题标题】:Sleuth not sending trace information to Zipkin侦探没有向 Zipkin 发送跟踪信息
【发布时间】:2017-12-06 09:31:36
【问题描述】:

即使 Zipkin 运行良好,Sleuth 也不会向 Zipkin 发送跟踪信息。 我正在使用 Spring 1.5.8.RELEASE、spring cloud Dalston.SR4,并在我的微服务中添加了以下依赖项:

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

我的日志总是假的: [FOOMS,2e740f33c26e286d,2e740f33c26e286d,假]

我的 Zipkin 依赖项是:

<dependency>
    <groupId>io.zipkin.java</groupId>
    <artifactId>zipkin-server</artifactId>
</dependency>
<dependency>
    <groupId>io.zipkin.java</groupId>
    <artifactId>zipkin-autoconfigure-ui</artifactId>
    <scope>runtime</scope>
</dependency>

为什么我的 slueth 陈述是假的而不是真的?但是,为所有调用正确生成了 traceId 和 SpanId。我的 Zipkin 在 9411 端口运行

【问题讨论】:

    标签: java spring spring-boot zipkin spring-cloud-sleuth


    【解决方案1】:

    我发现我需要添加采样器百分比。默认情况下,发送的样本百分比为零,这就是侦探没有向 zipkin 发送任何内容的原因。当我在属性文件中添加spring.sleuth.sampler.percentage=1.0 时,它开始工作了。

    【讨论】:

    • cloud.spring.io/spring-cloud-static/Edgware.RELEASE/multi/…IMPORTANT 部分中写道: > 如果使用 Zipkin,则使用 spring.sleuth.sampler.percentage 配置导出的跨度百分比(默认为 0.1,即 10%)。否则你可能会认为 Sleuth 没有工作,因为它忽略了一些跨度。
    • 在最近的版本中,密钥更改为“spring.sleuth.sampler.probability”。
    【解决方案2】:

    最新版云依赖&lt;version&gt;Finchley.SR2&lt;/version&gt;
    向 zipkin 发送跟踪的正确属性是:spring.sleuth.sampler.probability=1.0 这已经从百分比变为概率。

    【讨论】:

      【解决方案3】:

      如果要将所有 span 数据导出到 Zipkin,可以通过在 Spring boot 主类中创建 bean 定义来安装 sampler

        @Bean
        public Sampler defaultSampler() {
          return new AlwaysSampler();
        }
      

      【讨论】:

        猜你喜欢
        • 2022-06-15
        • 1970-01-01
        • 1970-01-01
        • 2020-07-27
        • 1970-01-01
        • 2019-07-25
        • 1970-01-01
        • 1970-01-01
        • 2019-12-02
        相关资源
        最近更新 更多