Class ExecutorServiceMetrics

java.lang.Object
io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics
All Implemented Interfaces:
MeterBinder

@NonNullApi
@NonNullFields
public class ExecutorServiceMetrics
extends java.lang.Object
implements MeterBinder
Monitors the status of executor service pools. Does not record timings on operations executed in the ExecutorService, as this requires the instance to be wrapped. Timings are provided separately by wrapping the executor service with TimedExecutorService.

Supports ThreadPoolExecutor and ForkJoinPool types of ExecutorService. Some libraries may provide a wrapper type for ExecutorService, like TimedExecutorService. Make sure to pass the underlying, unwrapped ExecutorService to this MeterBinder, if it is wrapped in another type.

  • Constructor Summary

    Constructors
    Constructor Description
    ExecutorServiceMetrics​(java.util.concurrent.ExecutorService executorService, java.lang.String executorServiceName, java.lang.Iterable<Tag> tags)  
    ExecutorServiceMetrics​(java.util.concurrent.ExecutorService executorService, java.lang.String executorServiceName, java.lang.String metricPrefix, java.lang.Iterable<Tag> tags)
    Create an ExecutorServiceMetrics instance.
  • Method Summary

    Modifier and Type Method Description
    void bindTo​(MeterRegistry registry)  
    static void disableIllegalReflectiveAccess()
    Disable illegal reflective accesses.
    static java.util.concurrent.Executor monitor​(MeterRegistry registry, java.util.concurrent.Executor executor, java.lang.String executorName, Tag... tags)
    Record metrics on the use of an Executor.
    static java.util.concurrent.Executor monitor​(MeterRegistry registry, java.util.concurrent.Executor executor, java.lang.String executorName, java.lang.Iterable<Tag> tags)
    Record metrics on the use of an Executor.
    static java.util.concurrent.Executor monitor​(MeterRegistry registry, java.util.concurrent.Executor executor, java.lang.String executorName, java.lang.String metricPrefix, Tag... tags)
    Record metrics on the use of an Executor.
    static java.util.concurrent.Executor monitor​(MeterRegistry registry, java.util.concurrent.Executor executor, java.lang.String executorName, java.lang.String metricPrefix, java.lang.Iterable<Tag> tags)
    Record metrics on the use of an Executor.
    static java.util.concurrent.ExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ExecutorService executor, java.lang.String executorServiceName, Tag... tags)
    Record metrics on the use of an ExecutorService.
    static java.util.concurrent.ExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ExecutorService executor, java.lang.String executorServiceName, java.lang.Iterable<Tag> tags)
    Record metrics on the use of an ExecutorService.
    static java.util.concurrent.ExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ExecutorService executor, java.lang.String executorServiceName, java.lang.String metricPrefix, Tag... tags)
    Record metrics on the use of an ExecutorService.
    static java.util.concurrent.ExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ExecutorService executor, java.lang.String executorServiceName, java.lang.String metricPrefix, java.lang.Iterable<Tag> tags)
    Record metrics on the use of an ExecutorService.
    static java.util.concurrent.ScheduledExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ScheduledExecutorService executor, java.lang.String executorServiceName, Tag... tags)
    Record metrics on the use of a ScheduledExecutorService.
    static java.util.concurrent.ScheduledExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ScheduledExecutorService executor, java.lang.String executorServiceName, java.lang.Iterable<Tag> tags)
    Record metrics on the use of a ScheduledExecutorService.
    static java.util.concurrent.ScheduledExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ScheduledExecutorService executor, java.lang.String executorServiceName, java.lang.String metricPrefix, Tag... tags)
    Record metrics on the use of a ScheduledExecutorService.
    static java.util.concurrent.ScheduledExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ScheduledExecutorService executor, java.lang.String executorServiceName, java.lang.String metricPrefix, java.lang.Iterable<Tag> tags)
    Record metrics on the use of a ScheduledExecutorService.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ExecutorServiceMetrics

      public ExecutorServiceMetrics​(@Nullable java.util.concurrent.ExecutorService executorService, java.lang.String executorServiceName, java.lang.Iterable<Tag> tags)
    • ExecutorServiceMetrics

      public ExecutorServiceMetrics​(@Nullable java.util.concurrent.ExecutorService executorService, java.lang.String executorServiceName, java.lang.String metricPrefix, java.lang.Iterable<Tag> tags)
      Create an ExecutorServiceMetrics instance.
      Parameters:
      executorService - executor service
      executorServiceName - executor service name which will be used as name tag
      metricPrefix - metrics prefix which will be used to prefix metric name
      tags - additional tags
      Since:
      1.5.0
  • Method Details

    • monitor

      public static java.util.concurrent.Executor monitor​(MeterRegistry registry, java.util.concurrent.Executor executor, java.lang.String executorName, java.lang.Iterable<Tag> tags)
      Record metrics on the use of an Executor.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The executor to instrument.
      executorName - Will be used to tag metrics with "name".
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented executor, proxied.
    • monitor

      public static java.util.concurrent.Executor monitor​(MeterRegistry registry, java.util.concurrent.Executor executor, java.lang.String executorName, java.lang.String metricPrefix, java.lang.Iterable<Tag> tags)
      Record metrics on the use of an Executor.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The executor to instrument.
      executorName - Will be used to tag metrics with "name".
      metricPrefix - The prefix to use with meter names. This differentiates executor metrics that may have different tag sets.
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented executor, proxied.
      Since:
      1.5.0
    • monitor

      public static java.util.concurrent.Executor monitor​(MeterRegistry registry, java.util.concurrent.Executor executor, java.lang.String executorName, Tag... tags)
      Record metrics on the use of an Executor.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The executor to instrument.
      executorName - Will be used to tag metrics with "name".
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented executor, proxied.
    • monitor

      public static java.util.concurrent.Executor monitor​(MeterRegistry registry, java.util.concurrent.Executor executor, java.lang.String executorName, java.lang.String metricPrefix, Tag... tags)
      Record metrics on the use of an Executor.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The executor to instrument.
      executorName - Will be used to tag metrics with "name".
      metricPrefix - The prefix to use with meter names. This differentiates executor metrics that may have different tag sets.
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented executor, proxied.
      Since:
      1.5.0
    • monitor

      public static java.util.concurrent.ExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ExecutorService executor, java.lang.String executorServiceName, java.lang.Iterable<Tag> tags)
      Record metrics on the use of an ExecutorService.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The executor to instrument.
      executorServiceName - Will be used to tag metrics with "name".
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented executor, proxied.
    • monitor

      public static java.util.concurrent.ExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ExecutorService executor, java.lang.String executorServiceName, java.lang.String metricPrefix, java.lang.Iterable<Tag> tags)
      Record metrics on the use of an ExecutorService.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The executor to instrument.
      executorServiceName - Will be used to tag metrics with "name".
      metricPrefix - The prefix to use with meter names. This differentiates executor metrics that may have different tag sets.
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented executor, proxied.
      Since:
      1.5.0
    • monitor

      public static java.util.concurrent.ExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ExecutorService executor, java.lang.String executorServiceName, Tag... tags)
      Record metrics on the use of an ExecutorService.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The executor to instrument.
      executorServiceName - Will be used to tag metrics with "name".
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented executor, proxied.
    • monitor

      public static java.util.concurrent.ExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ExecutorService executor, java.lang.String executorServiceName, java.lang.String metricPrefix, Tag... tags)
      Record metrics on the use of an ExecutorService.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The executor to instrument.
      executorServiceName - Will be used to tag metrics with "name".
      metricPrefix - The prefix to use with meter names. This differentiates executor metrics that may have different tag sets.
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented executor, proxied.
      Since:
      1.5.0
    • monitor

      public static java.util.concurrent.ScheduledExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ScheduledExecutorService executor, java.lang.String executorServiceName, java.lang.Iterable<Tag> tags)
      Record metrics on the use of a ScheduledExecutorService.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The scheduled executor to instrument.
      executorServiceName - Will be used to tag metrics with "name".
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented scheduled executor, proxied.
      Since:
      1.3.0
    • monitor

      public static java.util.concurrent.ScheduledExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ScheduledExecutorService executor, java.lang.String executorServiceName, java.lang.String metricPrefix, java.lang.Iterable<Tag> tags)
      Record metrics on the use of a ScheduledExecutorService.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The scheduled executor to instrument.
      executorServiceName - Will be used to tag metrics with "name".
      metricPrefix - The prefix to use with meter names. This differentiates executor metrics that may have different tag sets.
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented scheduled executor, proxied.
      Since:
      1.5.0
    • monitor

      public static java.util.concurrent.ScheduledExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ScheduledExecutorService executor, java.lang.String executorServiceName, Tag... tags)
      Record metrics on the use of a ScheduledExecutorService.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The scheduled executor to instrument.
      executorServiceName - Will be used to tag metrics with "name".
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented scheduled executor, proxied.
      Since:
      1.3.0
    • monitor

      public static java.util.concurrent.ScheduledExecutorService monitor​(MeterRegistry registry, java.util.concurrent.ScheduledExecutorService executor, java.lang.String executorServiceName, java.lang.String metricPrefix, Tag... tags)
      Record metrics on the use of a ScheduledExecutorService.
      Parameters:
      registry - The registry to bind metrics to.
      executor - The scheduled executor to instrument.
      executorServiceName - Will be used to tag metrics with "name".
      metricPrefix - The prefix to use with meter names. This differentiates executor metrics that may have different tag sets.
      tags - Tags to apply to all recorded metrics.
      Returns:
      The instrumented scheduled executor, proxied.
      Since:
      1.5.0
    • bindTo

      public void bindTo​(MeterRegistry registry)
      Specified by:
      bindTo in interface MeterBinder
    • disableIllegalReflectiveAccess

      public static void disableIllegalReflectiveAccess()
      Disable illegal reflective accesses. Java 9+ warns illegal reflective accesses, but some metrics from this binder depend on reflective access to Executors's internal implementation details. This method allows to disable the feature to avoid the warnings.
      Since:
      1.6.0