Class ExecutorServiceMetrics
java.lang.Object
io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics
- All Implemented Interfaces:
MeterBinder
@NonNullApi
@NonNullFields
public class ExecutorServiceMetrics
extends 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.
To use the following ExecutorService instances,
--add-opens java.base/java.util.concurrent=ALL-UNNAMED is required:
- Executors.newSingleThreadScheduledExecutor()
- Executors.newSingleThreadExecutor()
- Executors.newThreadPerTaskExecutor()
- Executors.newVirtualThreadPerTaskExecutor()
-
Constructor Summary
ConstructorsConstructorDescriptionExecutorServiceMetrics(ExecutorService executorService, String executorServiceName, Iterable<Tag> tags) ExecutorServiceMetrics(ExecutorService executorService, String executorServiceName, String metricPrefix, Iterable<Tag> tags) Create anExecutorServiceMetricsinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidbindTo(MeterRegistry registry) static voidDisable illegal reflective accesses.static Executormonitor(MeterRegistry registry, Executor executor, String executorName, Tag... tags) Record metrics on the use of anExecutor.static ExecutorRecord metrics on the use of anExecutor.static Executormonitor(MeterRegistry registry, Executor executor, String executorName, String metricPrefix, Tag... tags) Record metrics on the use of anExecutor.static Executormonitor(MeterRegistry registry, Executor executor, String executorName, String metricPrefix, Iterable<Tag> tags) Record metrics on the use of anExecutor.static ExecutorServicemonitor(MeterRegistry registry, ExecutorService executor, String executorServiceName, Tag... tags) Record metrics on the use of anExecutorService.static ExecutorServicemonitor(MeterRegistry registry, ExecutorService executor, String executorServiceName, Iterable<Tag> tags) Record metrics on the use of anExecutorService.static ExecutorServicemonitor(MeterRegistry registry, ExecutorService executor, String executorServiceName, String metricPrefix, Tag... tags) Record metrics on the use of anExecutorService.static ExecutorServicemonitor(MeterRegistry registry, ExecutorService executor, String executorServiceName, String metricPrefix, Iterable<Tag> tags) Record metrics on the use of anExecutorService.static ScheduledExecutorServicemonitor(MeterRegistry registry, ScheduledExecutorService executor, String executorServiceName, Tag... tags) Record metrics on the use of aScheduledExecutorService.static ScheduledExecutorServicemonitor(MeterRegistry registry, ScheduledExecutorService executor, String executorServiceName, Iterable<Tag> tags) Record metrics on the use of aScheduledExecutorService.static ScheduledExecutorServicemonitor(MeterRegistry registry, ScheduledExecutorService executor, String executorServiceName, String metricPrefix, Tag... tags) Record metrics on the use of aScheduledExecutorService.static ScheduledExecutorServicemonitor(MeterRegistry registry, ScheduledExecutorService executor, String executorServiceName, String metricPrefix, Iterable<Tag> tags) Record metrics on the use of aScheduledExecutorService.
-
Constructor Details
-
ExecutorServiceMetrics
public ExecutorServiceMetrics(@Nullable ExecutorService executorService, String executorServiceName, Iterable<Tag> tags) -
ExecutorServiceMetrics
public ExecutorServiceMetrics(@Nullable ExecutorService executorService, String executorServiceName, String metricPrefix, Iterable<Tag> tags) Create anExecutorServiceMetricsinstance.- Parameters:
executorService- executor serviceexecutorServiceName- executor service name which will be used as name tagmetricPrefix- metrics prefix which will be used to prefix metric nametags- additional tags- Since:
- 1.5.0
-
-
Method Details
-
monitor
public static Executor monitor(MeterRegistry registry, Executor executor, String executorName, Iterable<Tag> tags) Record metrics on the use of anExecutor.- 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 Executor monitor(MeterRegistry registry, Executor executor, String executorName, String metricPrefix, Iterable<Tag> tags) Record metrics on the use of anExecutor.- 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 Executor monitor(MeterRegistry registry, Executor executor, String executorName, Tag... tags) Record metrics on the use of anExecutor.- 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 Executor monitor(MeterRegistry registry, Executor executor, String executorName, String metricPrefix, Tag... tags) Record metrics on the use of anExecutor.- 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 ExecutorService monitor(MeterRegistry registry, ExecutorService executor, String executorServiceName, Iterable<Tag> tags) Record metrics on the use of anExecutorService.- 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 ExecutorService monitor(MeterRegistry registry, ExecutorService executor, String executorServiceName, String metricPrefix, Iterable<Tag> tags) Record metrics on the use of anExecutorService. This will also time the execution of tasks submitted to the ExecutorService wrapped withTimedExecutorServicereturned by this method. Metrics registered for monitoring theExecutorServicewill be removed when the wrappedExecutorServiceis shutdown.- 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 ExecutorService monitor(MeterRegistry registry, ExecutorService executor, String executorServiceName, Tag... tags) Record metrics on the use of anExecutorService.- 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 ExecutorService monitor(MeterRegistry registry, ExecutorService executor, String executorServiceName, String metricPrefix, Tag... tags) Record metrics on the use of anExecutorService.- 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 ScheduledExecutorService monitor(MeterRegistry registry, ScheduledExecutorService executor, String executorServiceName, Iterable<Tag> tags) Record metrics on the use of aScheduledExecutorService.- 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 ScheduledExecutorService monitor(MeterRegistry registry, ScheduledExecutorService executor, String executorServiceName, String metricPrefix, Iterable<Tag> tags) Record metrics on the use of aScheduledExecutorService.- 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 ScheduledExecutorService monitor(MeterRegistry registry, ScheduledExecutorService executor, String executorServiceName, Tag... tags) Record metrics on the use of aScheduledExecutorService.- 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 ScheduledExecutorService monitor(MeterRegistry registry, ScheduledExecutorService executor, String executorServiceName, String metricPrefix, Tag... tags) Record metrics on the use of aScheduledExecutorService.- 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
- Specified by:
bindToin interfaceMeterBinder
-
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 toExecutors's internal implementation details. This method allows to disable the feature to avoid the warnings.- Since:
- 1.6.0
-