Package io.micrometer.core.instrument
Interface LongTaskTimer
- All Superinterfaces:
HistogramSupport
,Meter
- All Known Implementing Classes:
CumulativeHistogramLongTaskTimer
,DefaultLongTaskTimer
,NoopLongTaskTimer
A long task timer is used to track the total duration of all in-flight long-running
tasks and the number of such tasks.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Fluent builder for long task timers.static class
Nested classes/interfaces inherited from interface io.micrometer.core.instrument.Meter
Meter.Id, Meter.Type
-
Method Summary
Modifier and TypeMethodDescriptionint
static LongTaskTimer.Builder
Create a timer builder from aTimed
annotation.static LongTaskTimer.Builder
default double
Deprecated.double
double
The amount of time the longest running task has been runningdefault double
default Iterable<Measurement>
measure()
Get a set of measurements.default void
Executes the runnablef
and records the time taken.default void
Executes the runnablef
and records the time taken.default <T> T
Executes the supplierf
and records the time taken.default <T> T
recordCallable
(Callable<T> f) Executes the callablef
and records the time taken.start()
Start keeping time for a task.default long
stop
(long task) Deprecated.Methods inherited from interface io.micrometer.core.instrument.distribution.HistogramSupport
takeSnapshot, takeSnapshot
-
Method Details
-
builder
-
builder
Create a timer builder from aTimed
annotation.- Parameters:
timed
- The annotation instance to base a new timer on.- Returns:
- This builder.
-
recordCallable
Executes the callablef
and records the time taken. -
record
Executes the supplierf
and records the time taken.- Type Parameters:
T
- The return type of theSupplier
.- Parameters:
f
- Function to execute and measure the execution time.- Returns:
- The return value of
f
.
-
record
Executes the runnablef
and records the time taken.- Parameters:
f
- Function to execute and measure the execution time with a reference to the timer id useful for looking up current duration.
-
record
Executes the runnablef
and records the time taken.- Parameters:
f
- Function to execute and measure the execution time.
-
start
LongTaskTimer.Sample start()Start keeping time for a task.- Returns:
- A task id that can be used to look up how long the task has been running.
-
duration
- Parameters:
unit
- The time unit to scale the duration to.- Returns:
- The cumulative duration of all current tasks.
-
activeTasks
int activeTasks()- Returns:
- The current number of tasks being executed.
-
mean
- Parameters:
unit
- The base unit of time to scale the mean to.- Returns:
- The distribution average for all recorded events.
- Since:
- 1.5.1
-
max
The amount of time the longest running task has been running- Parameters:
unit
- The time unit to scale the max to.- Returns:
- The maximum active task duration.
- Since:
- 1.5.0
-
baseTimeUnit
TimeUnit baseTimeUnit()- Returns:
- The base time unit of the long task timer to which all published metrics will be scaled
- Since:
- 1.5.0
-
stop
Deprecated.UseLongTaskTimer.Sample.stop()
. As of 1.5.0, this always returns -1 as tasks no longer have IDs.Mark a given task as completed.- Parameters:
task
- Id for the task to stop. This should be the value returned fromstart()
.- Returns:
- Duration for the task in nanoseconds. A -1 value will be returned for an unknown task.
-
duration
Deprecated.UseLongTaskTimer.Sample.duration(TimeUnit)
. As of 1.5.0, this always returns -1 as tasks no longer have IDs.The current duration for an active task.- Parameters:
task
- Id for the task to stop. This should be the value returned fromstart()
.unit
- The time unit to scale the duration to.- Returns:
- Duration for the task. A -1 value will be returned for an unknown task.
-
measure
Description copied from interface:Meter
Get a set of measurements. Should always return the same number of measurements and in the same order, regardless of the level of activity or the lack thereof.
-
LongTaskTimer.Sample.duration(TimeUnit)
.