Interface Timer
-
- All Superinterfaces:
Meter
- All Known Implementing Classes:
DropwizardTypes.DescribableTimer
public interface Timer extends Meter
Timer intended to track of a large number of short running events. Example would be something like an HTTP request. Though "short running" is a bit subjective the assumption is that it should be under a minute.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Timer.Builder
Fluent builder for timers.static class
Timer.Sample
-
Nested classes/interfaces inherited from interface org.forgerock.monitoring.api.instrument.Meter
Meter.Id, Meter.Type
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description TimeUnit
baseTimeUnit()
static Timer.Builder
builder(String name)
static Timer.Builder
builder(Timed timed, String defaultName)
Create a timer builder from aTimed
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.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.default void
record(Duration duration)
Updates the statistics kept by the counter with the specified amount.<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 Runnable
wrap(Runnable f)
Wrap aRunnable
so that it is timed when invoked.default <T> Callable<T>
wrap(Callable<T> f)
Wrap aCallable
so that it is timed when invoked.
-
-
-
Method Detail
-
start
static Timer.Sample start(MeterRegistry registry)
-
start
static Timer.Sample start(Clock clock)
-
builder
static Timer.Builder builder(String name)
-
builder
static Timer.Builder builder(Timed timed, String defaultName)
Create a timer builder from aTimed
annotation.- Parameters:
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.
-
record
void record(long amount, TimeUnit unit)
Updates the statistics kept by the counter with the specified amount.- Parameters:
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.
-
record
default void record(Duration duration)
Updates the statistics kept by the counter with the specified amount.- Parameters:
duration
- Duration of a single event being measured by this timer.
-
record
<T> T record(Supplier<T> f)
Executes the Supplier `f` and records the time taken.- Parameters:
f
- Function to execute and measure the execution time.- Returns:
- The return value of `f`.
-
recordCallable
<T> T recordCallable(Callable<T> f) throws Exception
Executes the callable `f` and records the time taken.- Parameters:
f
- Function to execute and measure the execution time.- Returns:
- The return value of `f`.
- Throws:
Exception
-
record
void record(Runnable f)
Executes the runnable `f` and records the time taken.- Parameters:
f
- Function to execute and measure the execution time.
-
wrap
default Runnable wrap(Runnable f)
Wrap aRunnable
so that it is timed when invoked.- Parameters:
f
- The Runnable to time when it is invoked.- Returns:
- The wrapped Runnable.
-
wrap
default <T> Callable<T> wrap(Callable<T> f)
Wrap aCallable
so that it is timed when invoked.- Parameters:
f
- The Callable to time when it is invoked.- Returns:
- The wrapped Callable.
-
count
long count()
The number of times that stop has been called on this timer.
-
totalTime
double totalTime(TimeUnit unit)
The total time of recorded events.
-
mean
default double mean(TimeUnit unit)
-
max
double max(TimeUnit unit)
The maximum time of a single event.
-
percentile
double percentile(double percentile, TimeUnit unit)
The latency at a specific percentile. This value is non-aggregable across dimensions.
-
histogramCountAtValue
double histogramCountAtValue(long valueNanos)
-
takeSnapshot
HistogramSnapshot takeSnapshot(boolean supportsAggregablePercentiles)
-
measure
default Iterable<Measurement> 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.
-
baseTimeUnit
TimeUnit baseTimeUnit()
-
-