Skip to content

Trace context does not propagate to the callback of ThreadPoolTaskExecutor/Scheduler #286

Open
@JasonMing

Description

@JasonMing
TracedThreadPoolTaskExecutor tracedExecutor = new TracedThreadPoolTaskExecutor(myExecutor, GlobalTracer.get());
try (Scope scope = GlobalTracer.activateSpan(span)) {
    ListenableFuture<?> future = tracedExecutor.submitListenable(() -> {
        Thread.sleep(1000); // Let callback run in other thread
        System.out.println(GlobalTracer.get().activeSpan()); // It's OK
    });
    future.addCallback(
        r -> System.out.println(GlobalTracer.get().activeSpan()), // Context loss!
        e -> {}
    );
}

This is confusing me, the context (activeSpan) is missed in the callback while the main task can get it correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions