vert.x and I’m having hundreds of coroutines running simultaneously. Now, I’m trying to differentiate logs on per coroutine basis.
What I’ve found so far is kotlin coroutines debug that enumerates every coroutine and adds this number to
After this, when my coroutines using
log4j2 logger theirs name is being calculated by retrieving coroutine name part from thread name (e.g. thread name “vertx-common-pool-7 @coroutine-10” will produce the name of the coroutine “coroutine-10”).
It almost suits my needs by I got several questions:
- What’s the overhead of using coroutines debug? Does the performance of the app going to suffer from this?
- Is it possible to do naming myself (instead of using coroutines debug)? I’ve tried adding
CoroutineContextbut it’s not very straightforward
- I’ve also tried modifying
Thread.namewhen launching new coroutines but this gets messy somehow (it ends up with multiple coroutines having the same names and number of different names equals to the number of event loops somehow).
Are there any recommendations to achieve the result of naming every coroutine for logging purposes?