public final class PercentileTimer extends Object implements Timer
Percentile timers are expensive compared to basic timers from the registry. In
particular they have a higher storage cost, worst case ~300x, to maintain the data
distribution. Be diligent about any additional dimensions added to percentile timers and
ensure they have a small bounded cardinality. In addition it is highly recommended to
set a range (see PercentileTimer.Builder.withRange(long, long, TimeUnit)) whenever possible to
greatly restrict the worst case overhead.
When using the builder (builder(Registry)), the range will default from 10 ms
to 1 minute. Based on data at Netflix this is the most common range for request latencies
and restricting to this window reduces the worst case multiple from 276 to 58
| Modifier and Type | Class and Description |
|---|---|
static class |
PercentileTimer.Builder
Helper for getting instances of a PercentileTimer.
|
Timer.BatchUpdater| Modifier and Type | Method and Description |
|---|---|
static IdBuilder<PercentileTimer.Builder> |
builder(Registry registry)
Return a builder for configuring and retrieving and instance of a percentile timer.
|
Clock |
clock()
The clock used for timing events.
|
long |
count()
The number of times that record has been called since this timer was last reset.
|
static PercentileTimer |
get(Registry registry,
Id id)
Creates a timer object that can be used for estimating percentiles.
|
boolean |
hasExpired()
Indicates whether the meter is expired.
|
Id |
id()
Identifier used to lookup this meter in the registry.
|
Iterable<Measurement> |
measure()
Get the set of measurements for this meter.
|
double |
percentile(double p)
Computes the specified percentile for this timer.
|
void |
record(long amount,
TimeUnit unit)
Updates the statistics kept by the timer with the specified amount.
|
long |
totalTime()
The total time in nanoseconds of all recorded events since this timer was last reset.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbatchUpdater, record, record, record, record, record, recordBooleanSupplier, recordCallable, recordDoubleSupplier, recordIntSupplier, recordLongSupplier, recordRunnable, recordSupplier, wrapBiConsumer, wrapBiFunction, wrapBinaryOperator, wrapBiPredicate, wrapBooleanSupplier, wrapCallable, wrapConsumer, wrapDoubleBinaryOperator, wrapDoubleConsumer, wrapDoubleFunction, wrapDoublePredicate, wrapDoubleSupplier, wrapDoubleToIntFunction, wrapDoubleToLongFunction, wrapDoubleUnaryOperator, wrapFunction, wrapIntBinaryOperator, wrapIntConsumer, wrapIntFunction, wrapIntPredicate, wrapIntSupplier, wrapIntToDoubleFunction, wrapIntToLongFunction, wrapIntUnaryOperator, wrapLongBinaryOperator, wrapLongConsumer, wrapLongFunction, wrapLongPredicate, wrapLongSupplier, wrapLongToDoubleFunction, wrapLongToIntFunction, wrapLongUnaryOperator, wrapObjDoubleConsumer, wrapObjIntConsumer, wrapObjLongConsumer, wrapPredicate, wrapRunnable, wrapSupplier, wrapToDoubleBiFunction, wrapToDoubleFunction, wrapToIntBiFunction, wrapToIntFunction, wrapToLongBiFunction, wrapToLongFunction, wrapUnaryOperatorpublic static PercentileTimer get(Registry registry, Id id)
PercentileTimer.Builder.withRange(long, long, TimeUnit)) whenever possible.registry - Registry to use.id - Identifier for the metric being registered.public static IdBuilder<PercentileTimer.Builder> builder(Registry registry)
public Id id()
Meterpublic Iterable<Measurement> measure()
Meterpublic boolean hasExpired()
MeterhasExpired in interface Meterpublic Clock clock()
Timerpublic void record(long amount,
TimeUnit unit)
Timerpublic double percentile(double p)
p - Percentile to compute, value must be 0.0 <= p <= 100.0.p`th percentile in seconds.public long count()
Timer