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 |
|---|---|
TimeUnit |
baseTimeUnit() |
static Timer.Builder |
builder(String name) |
static Timer.Builder |
builder(Timed timed,
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(TimeUnit unit) |
default double |
mean(TimeUnit unit) |
default Iterable<Measurement> |
measure()
Get a set of measurements.
|
default double |
percentile(double percentile,
TimeUnit unit)
Deprecated.
Use
HistogramSupport.takeSnapshot() to retrieve bucket counts. |
default void |
record(Duration duration)
Updates the statistics kept by the timer with the specified amount.
|
void |
record(long amount,
TimeUnit unit)
Updates the statistics kept by the timer with the specified amount.
|
void |
record(Runnable f)
Executes the runnable
f and records the time taken. |
<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()
Start a timing sample using the
System clock. |
static Timer.Sample |
start(Clock clock)
Start a timing sample.
|
static Timer.Sample |
start(MeterRegistry registry)
Start a timing sample.
|
double |
totalTime(TimeUnit unit) |
default <T> Callable<T> |
wrap(Callable<T> f)
Wrap a
Callable so that it is timed when invoked. |
default Runnable |
wrap(Runnable f)
Wrap a
Runnable so that it is timed when invoked. |
default <T> Supplier<T> |
wrap(Supplier<T> f)
Wrap a
Supplier so that it is timed when invoked. |
takeSnapshot, takeSnapshotstatic Timer.Sample start()
System clock.static Timer.Sample start(MeterRegistry registry)
registry - a meter registry whose clock is to be usedstatic Timer.Sample start(Clock clock)
clock - a clock to be usedstatic Timer.Builder builder(String name)
static Timer.Builder builder(Timed timed, 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,
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(Duration duration)
duration - Duration of a single event being measured by this timer.<T> T record(Supplier<T> f)
f and records the time taken.T - The return type of the Supplier.f - Function to execute and measure the execution time.f.<T> T recordCallable(Callable<T> f) throws Exception
f and records the time taken.void record(Runnable f)
f and records the time taken.f - Function to execute and measure the execution time.default Runnable wrap(Runnable f)
Runnable so that it is timed when invoked.f - The Runnable to time when it is invoked.default <T> Callable<T> wrap(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.default <T> Supplier<T> wrap(Supplier<T> f)
Supplier so that it is timed when invoked.T - The return type of the Supplier result.f - The Supplier to time when it is invoked.long count()
double totalTime(TimeUnit unit)
unit - The base unit of time to scale the total to.default double mean(TimeUnit unit)
unit - The base unit of time to scale the mean to.double max(TimeUnit unit)
unit - The base unit of time to scale the max to.default 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, 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.TimeUnit baseTimeUnit()
Copyright © 2020 LeanCloud. All rights reserved.