public interface LongTaskTimer extends Meter
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() |
static LongTaskTimer.Builder |
builder(java.lang.String name) |
static LongTaskTimer.Builder |
builder(Timed timed)
Create a timer builder from a
Timed annotation. |
double |
duration(long task,
java.util.concurrent.TimeUnit unit)
The current duration for an active task.
|
double |
duration(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.
|
long |
stop(long task)
Mark a given task as completed.
|
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
T
- The return type of the Callable
.f
- Function to execute and measure the execution time.java.lang.Exception
- Any exception bubbling up from the callable.default <T> T record(java.util.function.Supplier<T> f)
T
- The return type of the Supplier
.f
- Function to execute and measure the execution time.default void record(java.util.function.Consumer<LongTaskTimer.Sample> f)
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
- Function to execute and measure the execution time.LongTaskTimer.Sample start()
long stop(long task)
task
- Id for the task to stop. This should be the value returned from start()
.double duration(long task, java.util.concurrent.TimeUnit unit)
task
- Id for the task to stop. This should be the value returned from start()
.unit
- The time unit to scale the duration to.double duration(java.util.concurrent.TimeUnit unit)
unit
- The time unit to scale the duration to.int activeTasks()
default java.lang.Iterable<Measurement> measure()
Meter