Kotlin / kotlinx.coroutines

Library support for Kotlin coroutines
Apache License 2.0
13.07k stars 1.85k forks source link

Decide on each particular machinery of debug mode and provide an additional feature flag for each #3677

Open qwwdfsad opened 1 year ago

qwwdfsad commented 1 year ago

Currently, when coroutines debug mode is enabled, the following machinery is enabled:

qwwdfsad commented 1 year ago

My very first proposal is to completely get rid of setName -- it seems to cause more harm than good.

If you have any additional input about CancellationException stacktraces (or their absence) or CoroutineId -- please feel free to share, whether you are actively using them or, contrary, see no value in it.

qwwdfsad commented 1 year ago

Also, these feature flags should have a clear priority over debug mode -- it should be possible to e.g. enable stacktrace recovery without enabling debug mode itself for more fine-grained tuning

dovchinnikov commented 1 year ago

In IJ there is little to zero value in CoroutineId; we advise to use CoroutineName explicitly instead

qwwdfsad commented 1 year ago

UDP: Fleet disables stacktrace recovery because of setName overhead, but would like to enable it back

dovchinnikov commented 1 year ago

I'd also like to request a switch to include CoroutineName to toString representation of AbstractCoroutine (CoroutineId is not needed). At the moment our coroutine dump has to do it manually, and it does not help when it's not clear which coroutine was cancelled when JobCancellationException is printed to logs.