TraceAsyncListenableTaskExecutor implements AsyncListenableTaskExecutor { @Override public ListenableFuture<?> submitListenable(Runnable task) { return this.delegate.submitListenable(this.tracing.currentTraceContext().wrap(task)); } TraceAsyncListenableTaskExecutor(AsyncListenableTaskExecutor delegate, Tracing tracing); @Override ListenableFuture<?> submitListenable(Runnable task); @Override ListenableFuture<T> submitListenable(Callable<T> task); @Override void execute(Runnable task, long startTimeout); @Override Future<?> submit(Runnable task); @Override Future<T> submit(Callable<T> task); @Override void execute(Runnable task);  }
@Test public void should_submit_listenable_trace_runnable() throws Exception { AtomicBoolean executed = new AtomicBoolean(); Span span = this.tracer.nextSpan().name("foo"); try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(span.start())) { this.traceAsyncListenableTaskExecutor.submitListenable(aRunnable(this.tracing, executed)).get(); } finally { span.finish(); } BDDAssertions.then(executed.get()).isTrue(); }
@Test public void should_submit_listenable_trace_callable() throws Exception { Span span = this.tracer.nextSpan().name("foo"); Span spanFromListenable; try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(span.start())) { spanFromListenable = this.traceAsyncListenableTaskExecutor.submitListenable(aCallable(this.tracing)).get(); } finally { span.finish(); } BDDAssertions.then(spanFromListenable).isNotNull(); }