use of io.opentracing.util.AutoFinishScope.Continuation in project opentracing-java by opentracing.
the class Client method send.
public Future<Object> send(final Object message, final long milliseconds) {
Scope scope = tracer.scopeManager().active();
final Continuation cont = ((AutoFinishScope) scope).capture();
return executor.submit(new Callable<Object>() {
@Override
public Object call() throws Exception {
logger.info("Child thread with message '{}' started", message);
try (Scope parentScope = cont.activate()) {
try (Scope subtaskScope = tracer.buildSpan("subtask").startActive(false)) {
// Simulate work.
sleep(milliseconds);
}
}
logger.info("Child thread with message '{}' finished", message);
return message + "::response";
}
});
}
Aggregations