Reputation: 3264
I got a Spring Boot application making use of Spring Sleuth for tracing inter-service calls. Within that application a ScheduledExecutorService exists that performs http requests in a loop (pseudo-code below):
class HttpCaller implements Runnable {
public void run() {
performHttpCall();
// "loop"
executor.submit(this::run);
}
}
// start it once
scheduler.submit(new HttpCaller());
If I now have a look at the traces produced by Sleuth and stored in Zipkin I can see that all http calls are associated to a single Trace. Most likely because the trace context is handed over during the call to ScheduledExecutorService::submit
.
How can I clear the current trace before starting the next iteration so that each http call will result in a new detached/orphaned trace?
Upvotes: 4
Views: 1330
Reputation: 11189
If you're using Sleuth 2.0 you can call on the Tracer
a method to create a new trace. In the older version of sleuth I guess what I'd do is to use an executor that is NOT a bean. That way you would lose the trace and it would get restarted at some point (by rest template or sth like that).
Upvotes: 1