Expose ThreadPoolTaskExecutor queue size and capacity for metrics
We use Grafana to monitor our app via Spring's JMX exporter, and we think it could be interesting to have at least the current queue size for this purpose since the queue size directly affects the app memory load. Having the queue capacity seems also interesting to set up triggers whose values are calculated based on the maximum capacity of the queue. This commit introduces new getCurrentQueueSize() and getQueueCapacity() methods in ThreadPoolTaskExecutor. See gh-28583
This commit is contained in:
@@ -315,6 +315,20 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
|
||||
}
|
||||
return this.threadPoolExecutor.getPoolSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current number of threads waiting in the queue
|
||||
*/
|
||||
public int getCurrentQueueSize() {
|
||||
return this.getThreadPoolExecutor().getQueue().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the maximum capacity of the queue
|
||||
*/
|
||||
public int getQueueCapacity() {
|
||||
return this.queueCapacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of currently active threads.
|
||||
|
||||
Reference in New Issue
Block a user