Search in sources :

Example 1 with Continuation

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";
        }
    });
}
Also used : Continuation(io.opentracing.util.AutoFinishScope.Continuation) AutoFinishScope(io.opentracing.util.AutoFinishScope) Scope(io.opentracing.Scope) AutoFinishScope(io.opentracing.util.AutoFinishScope)

Aggregations

Scope (io.opentracing.Scope)1 AutoFinishScope (io.opentracing.util.AutoFinishScope)1 Continuation (io.opentracing.util.AutoFinishScope.Continuation)1