public interface Timer extends Meter, HistogramSupport
Modifier and Type | Interface and Description |
---|---|
static class |
Timer.Builder
Fluent builder for timers.
|
static class |
Timer.Sample
Maintains state on the clock's start position for a latency sample.
|
Meter.Id, Meter.Type
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.TimeUnit |
baseTimeUnit() |
static Timer.Builder |
builder(java.lang.String name) |
static Timer.Builder |
builder(Timed timed,
java.lang.String defaultName)
Create a timer builder from a
Timed annotation. |
long |
count() |
default double |
histogramCountAtValue(long valueNanos)
Deprecated.
Use
HistogramSupport.takeSnapshot() to retrieve bucket counts. |
double |
max(java.util.concurrent.TimeUnit unit) |
default double |
mean(java.util.concurrent.TimeUnit unit) |
default java.lang.Iterable<Measurement> |
measure()
Get a set of measurements.
|
default double |
percentile(double percentile,
java.util.concurrent.TimeUnit unit)
Deprecated.
Use
HistogramSupport.takeSnapshot() to retrieve bucket counts. |
default void |
record(java.time.Duration duration)
Updates the statistics kept by the counter with the specified amount.
|
void |
record(long amount,
java.util.concurrent.TimeUnit unit)
Updates the statistics kept by the counter with the specified amount.
|
void |
record(java.lang.Runnable f)
Executes the runnable `f` and records the time taken.
|
<T> T |
record(java.util.function.Supplier<T> f)
Executes the Supplier `f` and records the time taken.
|
<T> T |
recordCallable(java.util.concurrent.Callable<T> f)
Executes the callable `f` and records the time taken.
|
static Timer.Sample |
start(Clock clock) |
static Timer.Sample |
start(MeterRegistry registry) |
double |
totalTime(java.util.concurrent.TimeUnit unit) |
default <T> java.util.concurrent.Callable<T> |
wrap(java.util.concurrent.Callable<T> f)
Wrap a
Callable so that it is timed when invoked. |
default java.lang.Runnable |
wrap(java.lang.Runnable f)
Wrap a
Runnable so that it is timed when invoked. |
getId, takeSnapshot, takeSnapshot
static Timer.Sample start(MeterRegistry registry)
static Timer.Sample start(Clock clock)
static Timer.Builder builder(java.lang.String name)
static Timer.Builder builder(Timed timed, java.lang.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, java.util.concurrent.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(java.time.Duration duration)
duration
- Duration of a single event being measured by this timer.<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.<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.void record(java.lang.Runnable f)
f
- Function to execute and measure the execution time.default java.lang.Runnable wrap(java.lang.Runnable f)
Runnable
so that it is timed when invoked.f
- The Runnable to time when it is invoked.default <T> java.util.concurrent.Callable<T> wrap(java.util.concurrent.Callable<T> f)
Callable
so that it is timed when invoked.T
- The return type of the callable.f
- The Callable to time when it is invoked.long count()
double totalTime(java.util.concurrent.TimeUnit unit)
unit
- The base unit of time to scale the total to.default double mean(java.util.concurrent.TimeUnit unit)
unit
- The base unit of time to scale the mean to.double max(java.util.concurrent.TimeUnit unit)
unit
- The base unit of time to scale the max to.default java.lang.Iterable<Measurement> measure()
Meter
@Deprecated default double histogramCountAtValue(long valueNanos)
HistogramSupport.takeSnapshot()
to retrieve bucket counts.valueNanos
- The histogram bucket to retrieve a count for.@Deprecated default double percentile(double percentile, java.util.concurrent.TimeUnit unit)
HistogramSupport.takeSnapshot()
to retrieve bucket counts.percentile
- A percentile in the domain [0, 1]. For example, 0.5 represents the 50th percentile of the
distribution.unit
- The base unit of time to scale the percentile value to.java.util.concurrent.TimeUnit baseTimeUnit()