Skip to content

Commit

Permalink
Expose ThreadPoolTaskExecutor queue size and capacity for metrics
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rguihard authored and sbrannen committed Jun 8, 2022
1 parent 4912c3c commit e386bdb
Showing 1 changed file with 14 additions and 0 deletions.
Expand Up @@ -315,6 +315,20 @@ public int getPoolSize() {
}
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.
Expand Down

0 comments on commit e386bdb

Please sign in to comment.