Module org.elasticsearch.server
Package org.elasticsearch.common.metrics
Class ExponentialBucketHistogram
java.lang.Object
org.elasticsearch.common.metrics.ExponentialBucketHistogram
- Direct Known Subclasses:
HandlingTimeTracker
A histogram with a fixed number of buckets of exponentially increasing width.
The bucket boundaries are defined by increasing powers of two, e.g.
(-∞, 1), [1, 2), [2, 4), [4, 8), ..., [2^(
There are bucketCount
-2), ∞)
bucketCount
buckets.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addObservation
(long observedValue) int[]
void
clear()
Clear all values in the histogram (non-atomic)static int[]
getBucketUpperBounds
(int bucketCount) long
getPercentile
(float percentile) Calculate the Nth percentile valuelong
getPercentile
(float percentile, long[] snapshot, int[] bucketUpperBounds) Calculate the Nth percentile valuelong[]
-
Constructor Details
-
ExponentialBucketHistogram
public ExponentialBucketHistogram(int bucketCount)
-
-
Method Details
-
getBucketUpperBounds
public static int[] getBucketUpperBounds(int bucketCount) -
calculateBucketUpperBounds
public int[] calculateBucketUpperBounds() -
addObservation
public void addObservation(long observedValue) -
getSnapshot
public long[] getSnapshot()- Returns:
- An array of frequencies of handling times in buckets with upper bounds as returned by
calculateBucketUpperBounds()
, plus an extra bucket for handling times longer than the longest upper bound.
-
getPercentile
public long getPercentile(float percentile) Calculate the Nth percentile value- Parameters:
percentile
- The percentile as a fraction (in [0, 1.0])- Returns:
- A value greater than the specified fraction of values in the histogram
- Throws:
IllegalArgumentException
- if the requested percentile is invalid
-
getPercentile
public long getPercentile(float percentile, long[] snapshot, int[] bucketUpperBounds) Calculate the Nth percentile value- Parameters:
percentile
- The percentile as a fraction (in [0, 1.0])snapshot
- An array of frequencies of handling times in buckets with upper bounds as percalculateBucketUpperBounds()
bucketUpperBounds
- The upper bounds of the buckets in the histogram, as percalculateBucketUpperBounds()
- Returns:
- A value greater than the specified fraction of values in the histogram
- Throws:
IllegalArgumentException
- if the requested percentile is invalid
-
clear
public void clear()Clear all values in the histogram (non-atomic)
-