Class ThreadPoolMetrics


  • public class ThreadPoolMetrics
    extends java.lang.Object
    Metrics for ThreadPoolExecutor.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ACTIVE_TASKS  
      com.codahale.metrics.Gauge<java.lang.Integer> activeTasks
      Number of active tasks.
      static java.lang.String COMPLETED_TASKS  
      com.codahale.metrics.Gauge<java.lang.Long> completedTasks
      Number of completed tasks.
      com.codahale.metrics.Counter currentBlocked
      Number of tasks currently blocked, waiting to be accepted by the executor (because all threads are busy and the backing queue is full).
      static java.lang.String CURRENTLY_BLOCKED_TASKS  
      static java.lang.String MAX_POOL_SIZE  
      static java.lang.String MAX_TASKS_QUEUED  
      com.codahale.metrics.Gauge<java.lang.Integer> maxPoolSize
      Maximum number of threads before it will start queuing tasks
      com.codahale.metrics.Gauge<java.lang.Integer> maxTasksQueued
      Maximum number of tasks queued before a task get blocked
      static java.lang.String OLDEST_TASK_QUEUE_TIME  
      com.codahale.metrics.Gauge<java.lang.Long> oldestTaskQueueTime
      For how long the oldest task in the queue was queued
      java.lang.String path  
      static java.lang.String PENDING_TASKS  
      com.codahale.metrics.Gauge<java.lang.Integer> pendingTasks
      Number of tasks waiting to be executed.
      java.lang.String poolName  
      static java.lang.String TOTAL_BLOCKED_TASKS  
      com.codahale.metrics.Counter totalBlocked
      Number of tasks that had blocked before being accepted (or rejected).
    • Constructor Summary

      Constructors 
      Constructor Description
      ThreadPoolMetrics​(ResizableThreadPool executor, java.lang.String path, java.lang.String poolName)
      Create metrics for given ThreadPoolExecutor.
    • Field Detail

      • CURRENTLY_BLOCKED_TASKS

        public static final java.lang.String CURRENTLY_BLOCKED_TASKS
        See Also:
        Constant Field Values
      • TOTAL_BLOCKED_TASKS

        public static final java.lang.String TOTAL_BLOCKED_TASKS
        See Also:
        Constant Field Values
      • MAX_TASKS_QUEUED

        public static final java.lang.String MAX_TASKS_QUEUED
        See Also:
        Constant Field Values
      • OLDEST_TASK_QUEUE_TIME

        public static final java.lang.String OLDEST_TASK_QUEUE_TIME
        See Also:
        Constant Field Values
      • activeTasks

        public final com.codahale.metrics.Gauge<java.lang.Integer> activeTasks
        Number of active tasks.
      • pendingTasks

        public final com.codahale.metrics.Gauge<java.lang.Integer> pendingTasks
        Number of tasks waiting to be executed.
      • completedTasks

        public final com.codahale.metrics.Gauge<java.lang.Long> completedTasks
        Number of completed tasks.
      • currentBlocked

        public final com.codahale.metrics.Counter currentBlocked
        Number of tasks currently blocked, waiting to be accepted by the executor (because all threads are busy and the backing queue is full).
      • totalBlocked

        public final com.codahale.metrics.Counter totalBlocked
        Number of tasks that had blocked before being accepted (or rejected).
      • maxPoolSize

        public final com.codahale.metrics.Gauge<java.lang.Integer> maxPoolSize
        Maximum number of threads before it will start queuing tasks
      • oldestTaskQueueTime

        public final com.codahale.metrics.Gauge<java.lang.Long> oldestTaskQueueTime
        For how long the oldest task in the queue was queued
      • maxTasksQueued

        public final com.codahale.metrics.Gauge<java.lang.Integer> maxTasksQueued
        Maximum number of tasks queued before a task get blocked
      • path

        public final java.lang.String path
      • poolName

        public final java.lang.String poolName
    • Constructor Detail

      • ThreadPoolMetrics

        public ThreadPoolMetrics​(ResizableThreadPool executor,
                                 java.lang.String path,
                                 java.lang.String poolName)
        Create metrics for given ThreadPoolExecutor.
        Parameters:
        executor - Thread pool
        path - Type of thread pool
        poolName - Name of thread pool to identify metrics