|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.netflix.hystrix.util.HystrixRollingPercentile
public class HystrixRollingPercentile
Add values to a rolling window and retrieve percentile calculations such as median, 90th, 99th, etc.
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 Summary | |
|---|---|
HystrixRollingPercentile(HystrixProperty<java.lang.Integer> timeInMilliseconds,
HystrixProperty<java.lang.Integer> numberOfBuckets,
HystrixProperty<java.lang.Integer> bucketDataLength)
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HystrixRollingPercentile(HystrixProperty<java.lang.Integer> timeInMilliseconds,
HystrixProperty<java.lang.Integer> numberOfBuckets,
HystrixProperty<java.lang.Integer> bucketDataLength)
timeInMilliseconds - HystrixProperty<Integer> for nummber of milliseconds of data that should be tracked
Example: 60000 for 1 minute
numberOfBuckets - HystrixProperty<Integer> for number of buckets that the time window should be divided into
Example: 12 for 5 second buckets in a 1 minute window
bucketDataLength - HystrixProperty<Integer> for number of values stored in each bucket
Example: 1000 to store a max of 1000 values in each 5 second bucket
| Method Detail |
|---|
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()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||