How to extend/hand over trace to new thread #10001
-
Today I gave the auto instrumentation a try. It works well, except that it does not propagate the trace when creating a new thread (Class extending simple plain java.lang.Thread, and starting it with .start() method). Instead I get two distinct traces: The outer basically hanging there until the threads are collected, and a new trace for each thread created. How can I hand over the trace currently being in (trace ID, all metadata/labels/attributes/...) from the calling thread over to the new thread? Or should this happen automatically and I did something wrong? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
hi @MartinEmrich! check out #2527 and #9962 |
Beta Was this translation helpful? Give feedback.
@trask thanks!
Apparently creating threads directly with Thread.start() seems to be "bad practice" in 2023, so I "worked around" the issue by refactoring the affected code to use ExecutorService/Callable/Future instead of creating the threads directly.
Now I get one big Trace with all steps as expected.