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 classTimer.BuilderFluent builder for timers.static classTimer.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 TimeUnitbaseTimeUnit()static Timer.Builderbuilder(String name)static Timer.Builderbuilder(Timed timed, String defaultName)Create a timer builder from aTimedannotation.longcount()The number of times that stop has been called on this timer.doublehistogramCountAtValue(long valueNanos)doublemax(TimeUnit unit)The maximum time of a single event.default doublemean(TimeUnit unit)default Iterable<Measurement>measure()Get a set of measurements.doublepercentile(double percentile, TimeUnit unit)The latency at a specific percentile.voidrecord(long amount, TimeUnit unit)Updates the statistics kept by the counter with the specified amount.voidrecord(Runnable f)Executes the runnable `f` and records the time taken.default voidrecord(Duration duration)Updates the statistics kept by the counter with the specified amount.<T> Trecord(Supplier<T> f)Executes the Supplier `f` and records the time taken.<T> TrecordCallable(Callable<T> f)Executes the callable `f` and records the time taken.static Timer.Samplestart(Clock clock)static Timer.Samplestart(MeterRegistry registry)HistogramSnapshottakeSnapshot(boolean supportsAggregablePercentiles)doubletotalTime(TimeUnit unit)The total time of recorded events.default Runnablewrap(Runnable f)Wrap aRunnableso that it is timed when invoked.default <T> Callable<T>wrap(Callable<T> f)Wrap aCallableso 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 aTimedannotation.- 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 aRunnableso 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 aCallableso 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:MeterGet 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()
-
-