Monitoring metrics for coroutines in production


#1

Since coroutines has graduated to stable, we plan to adopt it in our code more heavily, goals being 1) saner async code than threads + callbacks, and 2) the ability to spawn tons of coroutines cheaply where threads would be expensive.

However, as we are working on something big enough that performance matters, we want to make sure that we are able to gain insights from our usage of coroutines instead of using it blindly. When using threads and executors, we are able to get, for example, the number of threads on each state (RUNNABLE, BLOCKED, etc.), threads that are queued, etc. These metrics can help (and have helped) us troubleshoot performance issues.

What would be the usual metrics that could be gathered from coroutines usage? How would they be used to gain insight on how the system is operating? And are there any tools available for this already?


#2

Anyone? :slightly_smiling_face:


#3

Since coroutines are cheap, I am not sure whether it makes sense to monitor anything in their regards.

Coroutines help with reducing the number of (blocked) threads. So, I guess, you could continue monitoring threads.