public interface LongTaskTimer extends Meter, HistogramSupport
Modifier and Type | Interface and Description |
---|---|
static class |
LongTaskTimer.Builder
Fluent builder for long task timers.
|
static class |
LongTaskTimer.Sample |
Meter.Id, Meter.Type
Modifier and Type | Method and Description |
---|---|
int |
activeTasks() |
java.util.concurrent.TimeUnit |
baseTimeUnit() |
static LongTaskTimer.Builder |
builder(java.lang.String name) |
static LongTaskTimer.Builder |
builder(Timed timed)
Create a timer builder from a
Timed annotation. |
default double |
duration(long task,
java.util.concurrent.TimeUnit unit)
Deprecated.
Use
LongTaskTimer.Sample.duration(TimeUnit) . As of 1.5.0, this always returns -1 as tasks no longer have IDs. |
double |
duration(java.util.concurrent.TimeUnit unit) |
double |
max(java.util.concurrent.TimeUnit unit)
The amount of time the longest running task has been running
|
default double |
mean(java.util.concurrent.TimeUnit unit) |
default java.lang.Iterable<Measurement> |
measure()
Get a set of measurements.
|
default void |
record(java.util.function.Consumer<LongTaskTimer.Sample> f)
Executes the runnable
f and records the time taken. |
default void |
record(java.lang.Runnable f)
Executes the runnable
f and records the time taken. |
default <T> T |
record(java.util.function.Supplier<T> f)
Executes the callable
f and records the time taken. |
default <T> T |
recordCallable(java.util.concurrent.Callable<T> f)
Executes the callable
f and records the time taken. |
LongTaskTimer.Sample |
start()
Start keeping time for a task.
|
default long |
stop(long task)
Deprecated.
Use
LongTaskTimer.Sample.stop() . As of 1.5.0, this always returns -1 as tasks no longer have IDs. |
takeSnapshot, takeSnapshot
static LongTaskTimer.Builder builder(java.lang.String name)
static LongTaskTimer.Builder builder(Timed timed)
Timed
annotation.timed
- The annotation instance to base a new timer on.default <T> T recordCallable(java.util.concurrent.Callable<T> f) throws java.lang.Exception
f
and records the time taken.T
- The return type of the Callable
.f
- Function to execute and measure the execution time.f
.java.lang.Exception
- Any exception bubbling up from the callable.default <T> T record(java.util.function.Supplier<T> f)
f
and records the time taken.T
- The return type of the Supplier
.f
- Function to execute and measure the execution time.f
.default void record(java.util.function.Consumer<LongTaskTimer.Sample> f)
f
and records the time taken.f
- Function to execute and measure the execution time with a reference to the
timer id useful for looking up current duration.default void record(java.lang.Runnable f)
f
and records the time taken.f
- Function to execute and measure the execution time.LongTaskTimer.Sample start()
double duration(java.util.concurrent.TimeUnit unit)
unit
- The time unit to scale the duration to.int activeTasks()
default double mean(java.util.concurrent.TimeUnit unit)
unit
- The base unit of time to scale the mean to.double max(java.util.concurrent.TimeUnit unit)
unit
- The time unit to scale the max to.java.util.concurrent.TimeUnit baseTimeUnit()
@Deprecated default long stop(long task)
LongTaskTimer.Sample.stop()
. As of 1.5.0, this always returns -1 as tasks no longer have IDs.task
- Id for the task to stop. This should be the value returned from start()
.@Deprecated default double duration(long task, java.util.concurrent.TimeUnit unit)
LongTaskTimer.Sample.duration(TimeUnit)
. As of 1.5.0, this always returns -1 as tasks no longer have IDs.task
- Id for the task to stop. This should be the value returned from start()
.unit
- The time unit to scale the duration to.default java.lang.Iterable<Measurement> measure()
Meter