【问题标题】:How to force Zipkin/Brave/Spring-Cloud-Sleuth span to be exportable?如何强制 Zipkin/Brave/Spring-Cloud-Sleuth 跨度可导出?
【发布时间】:2020-08-12 21:03:13
【问题描述】:

如何强制 Zipkin span 可导出? 在下面的代码中,span 有时是可导出的,有时不是不可重复的。

在我看来,如果我评论第一个 scopedSpan,则第二个手动创建的 spanInScope 是可导出的,但第一个 scopedSpan 如何防止第二个 spanInScope 可导出?它们是如何干扰的?

    @SneakyThrows
    private void debugScopedSpan(final String label) {
        ScopedSpan scopedSpan = tracer.startScopedSpan(label + "_1").tag("type", "manual");
        try {
            log.info("===== debugScopedSpan_1 {}", label);
        } catch (RuntimeException | Error e) {
            scopedSpan.error(e);
            throw e;
        } finally {
            scopedSpan.finish();
        }

        // Why both above scopedSpan and below spanInScope cant be exportable at the same time??? How do they iterfere with each other?

        Span trace = tracer.nextSpan().name(label+"_2").tag("type", "manual").start();
        final Tracer.SpanInScope spanInScope = tracer.withSpanInScope(trace);
        log.info("===== debugScopedSpan_2 {}", label);
        spanInScope.close();
        trace.finish();
    }

【问题讨论】:

    标签: spring-cloud-sleuth zipkin


    【解决方案1】:

    这是因为抽样。请创建一个采样器类型的 bean,其值可以是 Sampler.ALWAYS 或将概率属性设置为 1.0

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-01
      • 1970-01-01
      • 2021-10-25
      • 1970-01-01
      • 2019-04-12
      相关资源
      最近更新 更多