Package io.micrometer.core.instrument
Class AbstractTimer
java.lang.Object
io.micrometer.core.instrument.AbstractMeter
io.micrometer.core.instrument.AbstractTimer
- All Implemented Interfaces:
HistogramSupport
,Meter
,Timer
- Direct Known Subclasses:
CumulativeTimer
,DropwizardTimer
,StepTimer
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micrometer.core.instrument.Meter
Meter.Builder, Meter.Id, Meter.MeterProvider<T extends Meter>, Meter.Type
Nested classes/interfaces inherited from interface io.micrometer.core.instrument.Timer
Timer.Builder, Timer.ResourceSample, Timer.Sample
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractTimer
(Meter.Id id, Clock clock, DistributionStatisticConfig distributionStatisticConfig, PauseDetector pauseDetector, TimeUnit baseTimeUnit) Deprecated.Timer implementations should now declare at construction time whether they support aggregable percentiles or not.protected
AbstractTimer
(Meter.Id id, Clock clock, DistributionStatisticConfig distributionStatisticConfig, PauseDetector pauseDetector, TimeUnit baseTimeUnit, boolean supportsAggregablePercentiles) Creates a new timer.protected
AbstractTimer
(Meter.Id id, Clock clock, PauseDetector pauseDetector, TimeUnit baseTimeUnit, Histogram histogram) Creates a new timer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected static Histogram
defaultHistogram
(Clock clock, DistributionStatisticConfig distributionStatisticConfig, boolean supportsAggregablePercentiles) Creates a default histogram.final void
Updates the statistics kept by the timer with the specified amount.void
Executes the runnablef
and records the time taken.boolean
Executes the Supplierf
and records the time taken.double
Executes the Supplierf
and records the time taken.int
Executes the Supplierf
and records the time taken.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.protected abstract void
recordNonNegative
(long amount, TimeUnit unit) Summary statistics should be published off of a single snapshot instance so that, for example, there isn't disagreement between the distribution's bucket counts because more events continue to stream in.Methods inherited from class io.micrometer.core.instrument.AbstractMeter
equals, getId, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micrometer.core.instrument.distribution.HistogramSupport
takeSnapshot
-
Field Details
-
clock
-
histogram
-
-
Constructor Details
-
AbstractTimer
@Deprecated protected AbstractTimer(Meter.Id id, Clock clock, DistributionStatisticConfig distributionStatisticConfig, PauseDetector pauseDetector, TimeUnit baseTimeUnit) Deprecated.Timer implementations should now declare at construction time whether they support aggregable percentiles or not. By declaring it up front, Micrometer can memory optimize the histogram structure used to store distribution statistics.Creates a new timer.- Parameters:
id
- The timer's name and tags.clock
- The clock used to measure latency.distributionStatisticConfig
- Configuration determining which distribution statistics are sent.pauseDetector
- Compensation for coordinated omission.baseTimeUnit
- The time scale of this timer.
-
AbstractTimer
protected AbstractTimer(Meter.Id id, Clock clock, DistributionStatisticConfig distributionStatisticConfig, PauseDetector pauseDetector, TimeUnit baseTimeUnit, boolean supportsAggregablePercentiles) Creates a new timer.- Parameters:
id
- The timer's name and tags.clock
- The clock used to measure latency.distributionStatisticConfig
- Configuration determining which distribution statistics are sent.pauseDetector
- Compensation for coordinated omission.baseTimeUnit
- The time scale of this timer.supportsAggregablePercentiles
- Indicates whether the registry supports percentile approximations from histograms.
-
AbstractTimer
protected AbstractTimer(Meter.Id id, Clock clock, PauseDetector pauseDetector, TimeUnit baseTimeUnit, Histogram histogram) Creates a new timer.- Parameters:
id
- The timer's name and tags.clock
- The clock used to measure latency.pauseDetector
- Compensation for coordinated omission.baseTimeUnit
- The time scale of this timer.histogram
- Histogram.- Since:
- 1.11.0
-
-
Method Details
-
defaultHistogram
protected static Histogram defaultHistogram(Clock clock, DistributionStatisticConfig distributionStatisticConfig, boolean supportsAggregablePercentiles) Creates a default histogram.- Parameters:
clock
- The clock used to measure latency.distributionStatisticConfig
- Configuration determining which distribution statistics are sent.supportsAggregablePercentiles
- Indicates whether the registry supports percentile approximations from histograms.- Returns:
- a default histogram
- Since:
- 1.11.0
-
recordCallable
Description copied from interface:Timer
Executes the callablef
and records the time taken.- Specified by:
recordCallable
in interfaceTimer
- Type Parameters:
T
- The return type of theCallable
.- Parameters:
f
- Function to execute and measure the execution time.- Returns:
- The return value of
f
. - Throws:
Exception
- Any exception bubbling up from the callable.
-
record
Description copied from interface:Timer
Executes the Supplierf
and records the time taken. -
record
Description copied from interface:Timer
Executes the Supplierf
and records the time taken. -
record
Description copied from interface:Timer
Executes the Supplierf
and records the time taken. -
record
Description copied from interface:Timer
Executes the Supplierf
and records the time taken. -
record
Description copied from interface:Timer
Executes the Supplierf
and records the time taken. -
record
Description copied from interface:Timer
Executes the runnablef
and records the time taken. -
record
Description copied from interface:Timer
Updates the statistics kept by the timer with the specified amount. -
recordNonNegative
-
takeSnapshot
Description copied from interface:HistogramSupport
Summary statistics should be published off of a single snapshot instance so that, for example, there isn't disagreement between the distribution's bucket counts because more events continue to stream in.- Specified by:
takeSnapshot
in interfaceHistogramSupport
- Returns:
- A snapshot of all distribution statistics at a point in time.
-
baseTimeUnit
- Specified by:
baseTimeUnit
in interfaceTimer
- Returns:
- The base time unit of the timer to which all published metrics will be scaled
-
close
public void close()
-