opentracing-contrib / opentracing-contrib/java-spring-cloud

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

Open
#286 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
399
Forks
143
Avg merge
1d 3h
Merged PRs (30d)
22

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with TracedThreadPoolTaskExecutor and the submitListenable callback path, comparing how the task and callback obtain their tracing context. Use the supplied Java example to reproduce the missing activeSpan in the success and failure callbacks. Done means the callback observes the expected trace context as the main task does.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.