As a developer, I would like to monitor the size (and progress) of work in the Task Queues in the TaskSchedulers so that I can evaluate whether an experienced slowdown under production load is due to the magnitude or perhaps stall of tasks scheduled.
Normally I would simply attach the debugger and inspect task sizes, but:
- The application is running under mono and in production, so I cannot attach to it using visual studio
- I would like to deliver output of analysis on this data as surveillance input for health-monitoring of the service
I have been through the docs and found
- TaskScheduler.GetScheduledTasks, which delivers this information to the debugger. It is protected (which I could circumvent), but also seem to require some guarantees about frozen threads which I cannot honor. However, I am willing to use inconsistent data.
- how to get a list of running tasks in .net 4.0. Which focuses on the running Tasks, which are not that interesting to me. I am interested in the size of the backlog and whether work is progressing.
I am willing to:
- Use code designed for other purposes (such as for the debugger)
- Accept that i get inconsistent data (this is for statistics and analysis)
Things that I do not want to do are:
- Add tracking to each task created.
- Some of the code is 3rd party and cannot be refactored
- There is lots of code, and injecting this into that is worse than not being able to tell how it is progressing.
- Use a custom TaskScheduler
- Some of the code is 3rd party and cannot be refactored
- Some of the code use TaskSchedulers which sets thread-priority and max-concurrency. Factoring in the monitoring aspect would be awful.