Class VirtualThreadExecutorMetrics
java.lang.Object
ubic.gemma.core.metrics.binder.VirtualThreadExecutorMetrics
- All Implemented Interfaces:
io.micrometer.core.instrument.binder.MeterBinder
@ParametersAreNonnullByDefault
public class VirtualThreadExecutorMetrics
extends Object
implements io.micrometer.core.instrument.binder.MeterBinder
Micrometer binder for virtual-thread-per-task executors (JDK 21+).
Mirrors the ThreadPoolExecutorMetrics shape (pool-tagged counters and gauges) but works
for any ExecutorService — in particular Executors.newVirtualThreadPerTaskExecutor(),
which is not a ThreadPoolExecutor and therefore cannot be bound via
GenericExecutorMetrics.
Usage: construct with a pool name, call wrap(ExecutorService) to obtain an instrumented
executor (delegating; submission and execution counters increment around Executor.execute(Runnable)
and submit*), then register this binder with a MeterRegistry (typically by adding
it to the binder list in MetricsConfig).
Metrics emitted, all tagged pool=<name>:
gemma.executor.vt.submitted— total tasks submitted viaexecute/submit*gemma.executor.vt.active— tasks currently executinggemma.executor.vt.completed— total tasks that finished (success or failure)gemma.executor.vt.failed— tasks that completed by throwinggemma.executor.vt.queued— tasks submitted but not yet started (typically near zero for VT-per-task since each submission spawns a thread immediately; published for symmetry with platform-pool dashboards)gemma.executor.vt.task.duration— distribution of task execution time
- Author:
- claude
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbindTo(io.micrometer.core.instrument.MeterRegistry registry) wrap(ExecutorService delegate) Wrap a virtual-thread executor so thatexecuteandsubmit*increment the counters bound bybindTo(MeterRegistry).
-
Constructor Details
-
VirtualThreadExecutorMetrics
-
-
Method Details
-
bindTo
public void bindTo(io.micrometer.core.instrument.MeterRegistry registry) - Specified by:
bindToin interfaceio.micrometer.core.instrument.binder.MeterBinder
-
wrap
Wrap a virtual-thread executor so thatexecuteandsubmit*increment the counters bound bybindTo(MeterRegistry). All otherExecutorServicemethods (lifecycle, invokeAll/Any) pass through to the delegate; tasks scheduled throughinvokeAll/invokeAnyare instrumented at thesubmit*layer because those methods are implemented in terms of submit on the JDK VT executor — to keep the accounting unambiguous, this wrapper instruments at the boundary callers actually use (executeandsubmit*).
-