Skip to content

Use release 2.20.1 version,ThreadPoolExecutor will loses TraceId in some cases #14805

@LiouChong

Description

@LiouChong

Describe the bug

The traceId will be lost when the log is printed

Steps to reproduce

 private ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<>());

    @RequestMapping("/test/get/{value}")
    void test(@PathVariable("value") String value) throws InterruptedException {
        log.info("traceId :{}",  Span.current().getSpanContext().getTraceId());
        threadPoolExecutor.submit(() -> {
            log.info("thread pool info : {}, ",  Span.current().getSpanContext().getTraceId());
            try {
                Thread.sleep(10000L);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
    }

You can reproduce this by sending more than two requests (Just larger than the thread pool capacity + 1)within 10 seconds.

Expected behavior

Every log can record the traceId

Actual behavior

TraceId is not recorded in the logs after the second one.

Javaagent or library instrumentation version

2.20.1

Environment

JDK: 8
OS: Mac

Additional context

I use version 1.13.3(I just found an old version) and there is no such problem
I start my spring container using the following command:

-javaagent:/XXX/opentelemetry-javaagent-old.jar
-Dotel.traces.exporter=logging
-Dotel.metrics.exporter=none
-Dotel.logs.exporter=none

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneeds reproneeds triageNew issue that requires triage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions