public class HystrixRollingPercentile extends Object
The underlying data structure contains a circular array of buckets that "roll" over time.
For example, if the time window is configured to 60 seconds with 12 buckets of 5 seconds each, values will be captured in each 5 second bucket and rotate each 5 seconds.
This means that percentile calculations are for the "rolling window" of 55-60 seconds up to 5 seconds ago.
Each bucket will contain a circular array of long values and if more than the configured amount (1000 values for example) it will wrap around and overwrite values until time passes and a new bucket is allocated. This sampling approach for high volume metrics is done to conserve memory and reduce sorting time when calculating percentiles.
Constructor and Description |
---|
HystrixRollingPercentile(HystrixProperty<Integer> timeInMilliseconds,
HystrixProperty<Integer> numberOfBuckets,
HystrixProperty<Integer> bucketDataLength,
HystrixProperty<Boolean> enabled)
Deprecated.
Please use the constructor with non-configurable properties
HystrixRollingPercentile(Time, int, int, int, HystrixProperty |
HystrixRollingPercentile(int timeInMilliseconds,
int numberOfBuckets,
int bucketDataLength,
HystrixProperty<Boolean> enabled) |
Modifier and Type | Method and Description |
---|---|
void |
addValue(int... value)
Add value (or values) to current bucket.
|
int |
getMean()
This returns the mean (average) of all values in the current snapshot.
|
int |
getPercentile(double percentile)
Compute a percentile from the underlying rolling buckets of values.
|
void |
reset()
Force a reset so that percentiles start being gathered from scratch.
|
@Deprecated public HystrixRollingPercentile(HystrixProperty<Integer> timeInMilliseconds, HystrixProperty<Integer> numberOfBuckets, HystrixProperty<Integer> bucketDataLength, HystrixProperty<Boolean> enabled)
HystrixRollingPercentile(Time, int, int, int, HystrixProperty
timeInMilliseconds
- HystrixProperty<Integer>
for number of milliseconds of data that should be tracked
Note that this value is represented as a HystrixProperty
, but can not actually be modified
at runtime, to avoid data loss
Example: 60000 for 1 minute
numberOfBuckets
- HystrixProperty<Integer>
for number of buckets that the time window should be divided into
Note that this value is represented as a HystrixProperty
, but can not actually be modified
at runtime, to avoid data loss
Example: 12 for 5 second buckets in a 1 minute window
bucketDataLength
- HystrixProperty<Integer>
for number of values stored in each bucket
Note that this value is represented as a HystrixProperty
, but can not actually be modified
at runtime, to avoid data loss
Example: 1000 to store a max of 1000 values in each 5 second bucket
enabled
- HystrixProperty<Boolean>
whether data should be tracked and percentiles calculated.
If 'false' methods will do nothing.
public HystrixRollingPercentile(int timeInMilliseconds, int numberOfBuckets, int bucketDataLength, HystrixProperty<Boolean> enabled)
timeInMilliseconds
- number of milliseconds of data that should be tracked
Example: 60000 for 1 minute
numberOfBuckets
- number of buckets that the time window should be divided into
Example: 12 for 5 second buckets in a 1 minute window
bucketDataLength
- number of values stored in each bucket
Example: 1000 to store a max of 1000 values in each 5 second bucket
enabled
- HystrixProperty<Boolean>
whether data should be tracked and percentiles calculated.
If 'false' methods will do nothing.
public void addValue(int... value)
value
- Value to be stored in current bucket such as execution latency in millisecondspublic int getPercentile(double percentile)
For performance reasons it maintains a single snapshot of the sorted values from all buckets that is re-generated each time the bucket rotates.
This means that if a bucket is 5000ms, then this method will re-compute a percentile at most once every 5000ms.
percentile
- value such as 99 (99th percentile), 99.5 (99.5th percentile), 50 (median, 50th percentile) to compute and retrieve percentile from rolling buckets.public int getMean()
public void reset()
Copyright © 2015. All Rights Reserved.