Opentracing Brave生成相同的TraceId

问题描述


我正在一个JBoss Fuse项目中,我们需要跟踪对微服务的请求。我们正在使用Brave进行分布式跟踪。但是在某些请求之后,我们得到的TraceId与parentId不匹配,并且在重复。另一方面,我们每次都有一个唯一的ParentId,这很好。这个问题导致Zipkin上的图形表示不正确,在这里我们得到了不相关的嵌套请求。
        <bundle>mvn:io.zipkin.brave/brave/5.6.3</bundle>
        <bundle>mvn:io.zipkin.brave/brave-instrumentation-http/5.6.3</bundle>
        <bundle>mvn:io.zipkin.zipkin2/zipkin/2.12.9</bundle>
        <bundle>mvn:io.zipkin.reporter2/zipkin-reporter/2.8.0</bundle>
        <bundle>mvn:io.zipkin.reporter2/zipkin-sender-okhttp3/2.7.10</bundle>
        <bundle>mvn:org.jetbrains.kotlin/kotlin-osgi-bundle/1.3.10</bundle>
        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okhttp/3.11.0_1</bundle>
        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okio/1.15.0_1</bundle>
        <bundle>mvn:org.apache.cxf/cxf-integration-tracing-brave/3.1.17</bundle>

首先,我们认为问题出在Brave和Zipkin的不兼容版本中。我们已经修复了它,现在就像上面的代码片段一样,但是问题仍然存在。


在调试时,我们发现问题仅在Braves类ThreadLocalCurrentTraceContext中创建新的Span in方法时出现

@Override public Scope newScope(@Nullable TraceContext currentSpan) {
    final TraceContext prevIoUs = local.get();
    local.set(currentSpan);
    class ThreadLocalScope implements Scope {
      @Override public void close() {
        local.set(prevIoUs);
      }
    }
    Scope result = new ThreadLocalScope();
    return decorateScope(currentSpan,result);
  }
带有local.get()

返回非空值。 localfinal ThreadLocal<TraceContext>变量,仅在get方法返回空值时才有效。
知道我们如何解决这个问题或其他可能出现问题的可能性吗?谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)