Problem
I want to monitor the usage of a thread pool from a specific Scheduler (BoundedElasticScheduler
). I want to see if the thread pool capacity fits or if it gets to its limit quite often and if there are a lot of waiting tasks.
Question
I think the MAX usage of a threadpool is one of the most important metrics. Is there a metric that I haven't found yet that could be used for it? Or does someone have a hint for me how to observe thread usage in the pool and implement the metric myself?
Tried so far
- Using reactors build-in metrics
In reactor
3.4.x I found the metric executor.active
, but it is a gauge and in monitoring tools, this is polled in an interval (e.g. every minute), this is too inaccurate for short tasks that only last some milliseconds in the pool. In reactor
3.5 I found a max execution time, but not a max for the active threads amount. The documentations are heavily updated currently because of the 3.5 release, so maybe I miss a metric that could be used for what I need.
- Using a custom implementation to track usage
I've also tried to implement a DistributedSummary
around the scheduler, so I'm able to track the MAX scheduled tasks per time interval (since DistributedSummary
uses a TimeWindowMax
which will show the MAX per monitoring interval). But it will only track the scheduling itself, not the real thread usage, for example if you have a Mono which evaluates some Mono
s and Flux
inside, which will also use threads from the pool. So it doesn't show me the workload of the pool.
executor_pool_size_threads
is a gauge, so you would have to peek the value just at the right time when there is a max.executor_pool_max_threads
is showing the limit of the pool, not the max number of active threads. – Valise