【发布时间】:2018-09-16 02:59:57
【问题描述】:
我有一个Spring Boot 应用程序使用Spring Sleuth 来跟踪服务间调用。在该应用程序中存在一个ScheduledExecutorService,它在循环中执行 http 请求(下面的伪代码):
class HttpCaller implements Runnable {
public void run() {
performHttpCall();
// "loop"
executor.submit(this::run);
}
}
// start it once
scheduler.submit(new HttpCaller());
如果我现在查看由 Sleuth 生成并存储在 Zipkin 中的跟踪,我可以看到所有 http 调用都与单个跟踪相关联。很可能是因为跟踪上下文在调用ScheduledExecutorService::submit 期间被移交。
如何在开始下一次迭代之前清除当前跟踪,以便每个 http 调用都会产生一个新的分离/孤立跟踪?
【问题讨论】:
标签: spring zipkin spring-cloud-sleuth