How can I monitor the Task queues in the .NET TaskSchedulers (across AppDomain) -


as developer, monitor size (and progress) of work in task queues in taskschedulers can evaluate whether experienced slowdown under production load due magnitude or perhaps stall of tasks scheduled.

normally attach debugger , inspect task sizes, but:

  1. the application running under mono , in production, cannot attach using visual studio
  2. i deliver output of analysis on data surveillance input health-monitoring of service

i have been through docs , found

i willing to:

  1. use code designed other purposes (such debugger)
  2. accept inconsistent data (this statistics , analysis)

things not want are:

  1. add tracking each task created.
    • some of code 3rd party , cannot refactored
    • there lots of code, , injecting worse not being able tell how progressing.
  2. use custom taskscheduler
    • some of code 3rd party , cannot refactored
    • some of code use taskschedulers sets thread-priority , max-concurrency. factoring in monitoring aspect awful.

unfortunately taskscheduler.getscheduledtasks designed debuggers , there no direct way scheduled tasks.

but msdn says (source):

developers implementing custom debuggers shouldn't call method directly, should use internal wrapper method getscheduledtasksfordebugger instead: internal task[] getscheduledtasksfordebugger(). wrapper method returns array of tasks instead of enumerable. retrieve list of active schedulers, use internal method internal static taskscheduler[] gettaskschedulersfordebugger(). static method returns array of active taskscheduler instances. can use getscheduledtasksfordebugger on each scheduler instance retrieve list of scheduled tasks.

so why not use reflection? safe , easy way achieve want because getscheduledtasksfordebugger exist in future , it's designed debugging , profiling.


Popular posts from this blog