Package io.micrometer.core.instrument
Interface Timer
- All Superinterfaces:
HistogramSupport
,Meter
- All Known Implementing Classes:
AbstractTimer
,CumulativeTimer
,DropwizardTimer
,NoopTimer
,StepTimer
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
Modifier and TypeInterfaceDescriptionstatic class
Fluent builder for timers.static class
static class
Maintains state on the clock's start position for a latency sample.Nested classes/interfaces inherited from interface io.micrometer.core.instrument.Meter
Meter.Id, Meter.MeterProvider<T extends Meter>, Meter.Type
-
Method Summary
Modifier and TypeMethodDescriptionstatic Timer.Builder
Create a timer builder from aTimed
annotation.static Timer.Builder
long
count()
default double
histogramCountAtValue
(long valueNanos) Deprecated.double
default double
default Iterable
<Measurement> measure()
Get a set of measurements.default double
percentile
(double percentile, TimeUnit unit) Deprecated.UseHistogramSupport.takeSnapshot()
to retrieve bucket counts.void
Updates the statistics kept by the timer with the specified amount.void
Executes the runnablef
and records the time taken.default void
Updates the statistics kept by the timer with the specified amount.default boolean
Executes the Supplierf
and records the time taken.default double
Executes the Supplierf
and records the time taken.default int
Executes the Supplierf
and records the time taken.default long
Executes the Supplierf
and records the time taken.<T> T
Executes the Supplierf
and records the time taken.<T> T
recordCallable
(Callable<T> f) Executes the callablef
and records the time taken.static Timer.ResourceSample
resource
(MeterRegistry registry, String name) static Timer.Sample
start()
Start a timing sample using theSystem clock
.static Timer.Sample
Start a timing sample.static Timer.Sample
start
(MeterRegistry registry) Start a timing sample.double
default Runnable
Wrap aRunnable
so that it is timed when invoked.default <T> Callable
<T> Wrap aCallable
so that it is timed when invoked.default <T> Supplier
<T> Wrap aSupplier
so that it is timed when invoked.Methods inherited from interface io.micrometer.core.instrument.distribution.HistogramSupport
takeSnapshot, takeSnapshot
-
Method Details
-
start
Start a timing sample using theSystem clock
.- Returns:
- A timing sample with start time recorded.
- Since:
- 1.1.0
-
start
Start a timing sample.- Parameters:
registry
- A meter registry whose clock is to be used- Returns:
- A timing sample with start time recorded.
-
start
Start a timing sample.- Parameters:
clock
- a clock to be used- Returns:
- A timing sample with start time recorded.
-
builder
-
resource
@Incubating(since="1.6.0") static Timer.ResourceSample resource(MeterRegistry registry, String name) - Parameters:
registry
- A meter registry against which the timer will be registered.name
- The name of the timer.- Returns:
- A timing builder that automatically records a timing on close.
- Since:
- 1.6.0
-
builder
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.- Returns:
- This builder.
-
record
Updates the statistics kept by the timer 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
Updates the statistics kept by the timer with the specified amount.- Parameters:
duration
- Duration of a single event being measured by this timer.
-
record
Executes the Supplierf
and records the time taken.- Type Parameters:
T
- The return type of theSupplier
.- Parameters:
f
- Function to execute and measure the execution time.- Returns:
- The return value of
f
.
-
record
Executes the Supplierf
and records the time taken.- Parameters:
f
- Function to execute and measure the execution time.- Returns:
- The return value of
f
. - Since:
- 1.10.0
-
record
Executes the Supplierf
and records the time taken.- Parameters:
f
- Function to execute and measure the execution time.- Returns:
- The return value of
f
. - Since:
- 1.10.0
-
record
Executes the Supplierf
and records the time taken.- Parameters:
f
- Function to execute and measure the execution time.- Returns:
- The return value of
f
. - Since:
- 1.10.0
-
record
Executes the Supplierf
and records the time taken.- Parameters:
f
- Function to execute and measure the execution time.- Returns:
- The return value of
f
. - Since:
- 1.10.0
-
recordCallable
Executes the callablef
and records the time taken. -
record
Executes the runnablef
and records the time taken.- Parameters:
f
- Function to execute and measure the execution time.
-
wrap
Wrap aRunnable
so that it is timed when invoked.- Parameters:
f
- The Runnable to time when it is invoked.- Returns:
- The wrapped Runnable.
-
wrap
Wrap aCallable
so that it is timed when invoked.- Type Parameters:
T
- The return type of the callable.- Parameters:
f
- The Callable to time when it is invoked.- Returns:
- The wrapped callable.
-
wrap
Wrap aSupplier
so that it is timed when invoked.- Type Parameters:
T
- The return type of theSupplier
result.- Parameters:
f
- TheSupplier
to time when it is invoked.- Returns:
- The wrapped supplier.
- Since:
- 1.2.0
-
count
long count()- Returns:
- The number of times that stop has been called on this timer.
-
totalTime
- Parameters:
unit
- The base unit of time to scale the total to.- Returns:
- The total time of recorded events.
-
mean
- Parameters:
unit
- The base unit of time to scale the mean to.- Returns:
- The distribution average for all recorded events.
-
max
- Parameters:
unit
- The base unit of time to scale the max to.- Returns:
- The maximum time of a single event.
-
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. -
histogramCountAtValue
Deprecated.UseHistogramSupport.takeSnapshot()
to retrieve bucket counts.Provides cumulative histogram counts.- Parameters:
valueNanos
- The histogram bucket to retrieve a count for.- Returns:
- The count of all events less than or equal to the bucket. If valueNanos does not match a preconfigured bucket boundary, returns NaN.
-
percentile
Deprecated.UseHistogramSupport.takeSnapshot()
to retrieve bucket counts.- Parameters:
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.- Returns:
- The latency at a specific percentile. This value is non-aggregable across dimensions. Returns NaN if percentile is not a preconfigured percentile that Micrometer is tracking.
-
baseTimeUnit
TimeUnit baseTimeUnit()- Returns:
- The base time unit of the timer to which all published metrics will be scaled
-
HistogramSupport.takeSnapshot()
to retrieve bucket counts.