public interface Timer extends Meter
Modifier and Type | Interface and Description |
---|---|
static class |
Timer.Builder
Fluent builder for timers.
|
static class |
Timer.Sample |
Meter.Id, Meter.Type
Modifier and Type | Method and Description |
---|---|
TimeUnit |
baseTimeUnit() |
static Timer.Builder |
builder(String name) |
static Timer.Builder |
builder(Timed timed,
String defaultName)
Create a timer builder from a
Timed annotation. |
long |
count()
The number of times that stop has been called on this timer.
|
double |
histogramCountAtValue(long valueNanos) |
double |
max(TimeUnit unit)
The maximum time of a single event.
|
default double |
mean(TimeUnit unit) |
default Iterable<Measurement> |
measure()
Get a set of measurements.
|
double |
percentile(double percentile,
TimeUnit unit)
The latency at a specific percentile.
|
default void |
record(Duration duration)
Updates the statistics kept by the counter with the specified amount.
|
void |
record(long amount,
TimeUnit unit)
Updates the statistics kept by the counter with the specified amount.
|
void |
record(Runnable f)
Executes the runnable `f` and records the time taken.
|
<T> T |
record(Supplier<T> f)
Executes the Supplier `f` and records the time taken.
|
<T> T |
recordCallable(Callable<T> f)
Executes the callable `f` and records the time taken.
|
static Timer.Sample |
start(Clock clock) |
static Timer.Sample |
start(MeterRegistry registry) |
HistogramSnapshot |
takeSnapshot(boolean supportsAggregablePercentiles) |
double |
totalTime(TimeUnit unit)
The total time of recorded events.
|
default <T> Callable<T> |
wrap(Callable<T> f)
Wrap a
Callable so that it is timed when invoked. |
default Runnable |
wrap(Runnable f)
Wrap a
Runnable so that it is timed when invoked. |
static Timer.Sample start(MeterRegistry registry)
static Timer.Sample start(Clock clock)
static Timer.Builder builder(String name)
static Timer.Builder builder(Timed timed, String defaultName)
Timed
annotation.timed
- The annotation instance to base a new timer on.defaultName
- A default name to use in the event that the value attribute is empty.void record(long amount, TimeUnit unit)
amount
- Duration of a single event being measured by this timer. If the amount is less than 0
the value will be dropped.unit
- Time unit for the amount being recorded.default void record(Duration duration)
duration
- Duration of a single event being measured by this timer.<T> T record(Supplier<T> f)
f
- Function to execute and measure the execution time.<T> T recordCallable(Callable<T> f) throws Exception
f
- Function to execute and measure the execution time.Exception
void record(Runnable f)
f
- Function to execute and measure the execution time.default Runnable wrap(Runnable f)
Runnable
so that it is timed when invoked.f
- The Runnable to time when it is invoked.default <T> Callable<T> wrap(Callable<T> f)
Callable
so that it is timed when invoked.f
- The Callable to time when it is invoked.long count()
double totalTime(TimeUnit unit)
default double mean(TimeUnit unit)
double max(TimeUnit unit)
double percentile(double percentile, TimeUnit unit)
double histogramCountAtValue(long valueNanos)
HistogramSnapshot takeSnapshot(boolean supportsAggregablePercentiles)
default Iterable<Measurement> measure()
Meter
TimeUnit baseTimeUnit()
Copyright 2010-2022 ForgeRock AS.