Work with ThreadLocal-sensitive Components
See original GitHub issueMany application trace framework use ThreadLocal
to store the call context of a application, like the SLF4j MDC, CAT , and other distributed trace system(which use thread local for trace the context in some async situation).
But the coroutine will be dispatched to a unspecified thread to execute, how can i make the tracing work?
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Intro to ThreadLocal in Java - Developer.com
We look at the basic concepts behind the ThreadLocal class and how to work with it in the Java programming language. Learn more....
Read more >Java static code analysis: "ThreadLocal" variables should be ...
ThreadLocal variables are supposed to be garbage collected once the holding thread is no longer alive. Memory leaks can occur when holding threads...
Read more >ThreadLocal Internal Working - Anmol Sehgal
ThreadLocals are the famous components in any multithreaded environment. To explain it in nutshell, ... Internal Working of Thread Local.
Read more >Spring Request scope vs java thread-local - Stack Overflow
In code, using ThreadLocal: private static final ThreadLocal<SomeClass> myThreadLocal = new ThreadLocal<SomeClass>(); And for each http request ...
Read more >Better Performance Through Thread-local Emulation
tion for thread-local emulation, the software and hardware ... Copyrights for components of this work owned by others than.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We should really have it out-of-the box in a separate integration module.
API in PR #454 now looks like this. In your to use it you have to define your own context element that implements
ThreadContextElement
interface like this:The implementation is quite efficient now. Its cost is
O(N)
, whereN
is the size of the context (number of elements in the context). When a coroutine is resumed on a thread its context is scanned for elements that implementThreadContextElement
and they are given change to update the context of the thread.