panjf2000 / ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.
https://ants.andypan.me/
MIT License
12.69k stars 1.36k forks source link

[Question]: How to get meaningful statistics on a function pool? #293

Closed ivoras closed 1 year ago

ivoras commented 1 year ago

Questions with details

I'd like to log things like how many goroutines in a function pool (PoolWithFunc) are actually doing something (non-idle). I've tried logging pool.Running() but after a short ramp-up it always shows the maximum number of goroutines (i.e. the cap). The number returned by Waiting() is always 0, so it doesn't seem like the workers are stalled.

Is there a way to get the actual number of non-idle workers?

Code snippets (optional)

No response

panjf2000 commented 1 year ago

I think you have to make the statistics in your task function, it would be the most precise way to do that, inject statistics logic into your code and get the result you want.

ivoras commented 1 year ago

Thanks!