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.
-
Constructor Summary
ConstructorDescriptionExecutorServiceMetrics
(ExecutorService executorService, String executorServiceName, Iterable<Tag> tags) ExecutorServiceMetrics
(ExecutorService executorService, String executorServiceName, String metricPrefix, Iterable<Tag> tags) Create anExecutorServiceMetrics
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
bindTo
(MeterRegistry registry) static void
Disable illegal reflective accesses.static Executor
monitor
(MeterRegistry registry, Executor executor, String executorName, Tag... tags) Record metrics on the use of anExecutor
.static Executor
Record metrics on the use of anExecutor
.static Executor
monitor
(MeterRegistry registry, Executor executor, String executorName, String metricPrefix, Tag... tags) Record metrics on the use of anExecutor
.static Executor
monitor
(MeterRegistry registry, Executor executor, String executorName, String metricPrefix, Iterable<Tag> tags) Record metrics on the use of anExecutor
.static ExecutorService
monitor
(MeterRegistry registry, ExecutorService executor, String executorServiceName, Tag... tags) Record metrics on the use of anExecutorService
.static ExecutorService
monitor
(MeterRegistry registry, ExecutorService executor, String executorServiceName, Iterable<Tag> tags) Record metrics on the use of anExecutorService
.static ExecutorService
monitor
(MeterRegistry registry, ExecutorService executor, String executorServiceName, String metricPrefix, Tag... tags) Record metrics on the use of anExecutorService
.static ExecutorService
monitor
(MeterRegistry registry, ExecutorService executor, String executorServiceName, String metricPrefix, Iterable<Tag> tags) Record metrics on the use of anExecutorService
.static ScheduledExecutorService
monitor
(MeterRegistry registry, ScheduledExecutorService executor, String executorServiceName, Tag... tags) Record metrics on the use of aScheduledExecutorService
.static ScheduledExecutorService
monitor
(MeterRegistry registry, ScheduledExecutorService executor, String executorServiceName, Iterable<Tag> tags) Record metrics on the use of aScheduledExecutorService
.static ScheduledExecutorService
monitor
(MeterRegistry registry, ScheduledExecutorService executor, String executorServiceName, String metricPrefix, Tag... tags) Record metrics on the use of aScheduledExecutorService
.static ScheduledExecutorService
monitor
(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 anExecutorServiceMetrics
instance.- 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
.- 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:
bindTo
in 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
-