@Override public <T> ListenableFuture<T> submitListenable(Callable<T> task) { return this.delegate .submitListenable(this.tracing.currentTraceContext().wrap(task)); }
@Override public void execute(Runnable task) { this.delegate.execute(this.tracing.currentTraceContext().wrap(task)); }
@Override public ListenableFuture<?> submitListenable(Runnable task) { return this.delegate .submitListenable(this.tracing.currentTraceContext().wrap(task)); }
@Override public void execute(Runnable task, long startTimeout) { this.delegate.execute(this.tracing.currentTraceContext().wrap(task), startTimeout); }
@Override public <T> Future<T> submit(Callable<T> task) { return this.delegate.submit(this.tracing.currentTraceContext().wrap(task)); }
@Override public Future<?> submit(Runnable task) { return this.delegate.submit(this.tracing.currentTraceContext().wrap(task)); }
@Test public void attachesSpanInRunnable() throws Exception { Runnable runnable; try (Scope scope = currentTraceContext.newScope(context)) { runnable = currentTraceContext.wrap(() -> { assertThat(currentTraceContext.get()) .isEqualTo(context); verifyImplicitContext(context); }); runnable.run(); // runs assertion in the same scope } // Set another span between the time the task was made and executed. try (Scope scope2 = currentTraceContext.newScope(context2)) { runnable.run(); // runs assertion verifyImplicitContext(context2); } }
@Test public void attachesSpanInCallable() throws Exception { Callable<?> callable; try (Scope scope = currentTraceContext.newScope(context)) { callable = currentTraceContext.wrap(() -> { assertThat(currentTraceContext.get()) .isEqualTo(context); verifyImplicitContext(context); return true; }); callable.call(); // runs assertion in the same scope } // Set another span between the time the task was made and executed. try (Scope scope2 = currentTraceContext.newScope(context2)) { callable.call(); // runs assertion verifyImplicitContext(context2); } }
@Test public void attachesSpanInCallable_canClear() throws Exception { Callable<?> callable = currentTraceContext.wrap(() -> { assertThat(currentTraceContext.get()).isNull(); verifyImplicitContext(null); return true; }); // Set another span between the time the task was made and executed. try (Scope scope2 = currentTraceContext.newScope(context2)) { callable.call(); // runs assertion verifyImplicitContext(context2); } }
@Override public <T> ListenableFuture<T> submitListenable(Callable<T> task) { return this.delegate .submitListenable(this.tracing.currentTraceContext().wrap(task)); }
@Override public void execute(Runnable task, long startTimeout) { this.delegate.execute(this.tracing.currentTraceContext().wrap(task), startTimeout); }
@Override public ListenableFuture<?> submitListenable(Runnable task) { return this.delegate .submitListenable(this.tracing.currentTraceContext().wrap(task)); }
@Override public Future<?> submit(Runnable task) { return this.delegate.submit(this.tracing.currentTraceContext().wrap(task)); }
@Override public <T> Future<T> submit(Callable<T> task) { return this.delegate.submit(this.tracing.currentTraceContext().wrap(task)); }
@Override public void execute(Runnable task) { this.delegate.execute(this.tracing.currentTraceContext().wrap(task)); }
@Test public void attachesSpanInRunnable() throws Exception { Runnable runnable; try (Scope scope = currentTraceContext.newScope(context)) { runnable = currentTraceContext.wrap(() -> { assertThat(currentTraceContext.get()) .isEqualTo(context); verifyImplicitContext(context); }); runnable.run(); // runs assertion in the same scope } // Set another span between the time the task was made and executed. try (Scope scope2 = currentTraceContext.newScope(context2)) { runnable.run(); // runs assertion verifyImplicitContext(context2); } }
@Test public void attachesSpanInCallable() throws Exception { Callable<?> callable; try (Scope scope = currentTraceContext.newScope(context)) { callable = currentTraceContext.wrap(() -> { assertThat(currentTraceContext.get()) .isEqualTo(context); verifyImplicitContext(context); return true; }); callable.call(); // runs assertion in the same scope } // Set another span between the time the task was made and executed. try (Scope scope2 = currentTraceContext.newScope(context2)) { callable.call(); // runs assertion verifyImplicitContext(context2); } }
@Test public void attachesSpanInCallable_canClear() throws Exception { Callable<?> callable = currentTraceContext.wrap(() -> { assertThat(currentTraceContext.get()).isNull(); verifyImplicitContext(null); return true; }); // Set another span between the time the task was made and executed. try (Scope scope2 = currentTraceContext.newScope(context2)) { callable.call(); // runs assertion verifyImplicitContext(context2); } }