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(String name) |
static LongTaskTimer.Builder |
builder(Timed timed)
Create a timer builder from a
Timed annotation. |
double |
duration(long task,
TimeUnit unit)
The current duration for an active task.
|
double |
duration(TimeUnit unit) |
default Iterable<Measurement> |
measure()
Get a set of measurements.
|
default void |
record(Consumer<LongTaskTimer.Sample> f)
Executes the runnable
f and records the time taken. |
default void |
record(Runnable f)
Executes the runnable
f and records the time taken. |
default <T> T |
record(Supplier<T> f)
Executes the callable
f and records the time taken. |
default <T> T |
recordCallable(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(String name)
static LongTaskTimer.Builder builder(Timed timed)
Timed
annotation.timed
- The annotation instance to base a new timer on.default <T> T recordCallable(Callable<T> f) throws Exception
f
and records the time taken.default <T> T record(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(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(Runnable f)
f
and records the time taken.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, 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(TimeUnit unit)
unit
- The time unit to scale the duration to.int activeTasks()
default Iterable<Measurement> measure()
Meter
Copyright © 2019. All rights reserved.