C# Class Elders.Hystrix.NET.Util.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.

Afficher le fichier Open project: Elders/Hystrix.NET Class Usage Examples

Private Properties

Свойство Type Description
GetCurrentBucket Bucket
HystrixRollingPercentile System

Méthodes publiques

Méthode Description
AddValue ( ) : void

Add value (or values) to current bucket.

GetMean ( ) : int

Gets the mean (average) of all values in the current snapshot. This is not a percentile but often desired so captured and exposed here.

GetPercentile ( double percentile ) : int

Compute a percentile from the underlying rolling buckets of values.

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 5000 milliseconds, then this method will re-compute a percentile at most once every 5000 milliseconds.

HystrixRollingPercentile ( IHystrixProperty timeInMilliseconds, IHystrixProperty numberOfBuckets, IHystrixProperty bucketDataLength, IHystrixProperty enabled ) : System

Initializes a new instance of the HystrixRollingPercentile class.

Reset ( ) : void

Force a reset so that percentiles start being gathered from scratch.

Private Methods

Méthode Description
GetCurrentBucket ( ) : Bucket

Gets the current bucket. If the time is after the window of the current bucket, a new one will be created. Internal because it's used in unit tests.

HystrixRollingPercentile ( ITime time, IHystrixProperty timeInMilliseconds, IHystrixProperty numberOfBuckets, IHystrixProperty bucketDataLength, IHystrixProperty enabled ) : System

Initializes a new instance of the HystrixRollingPercentile class.

Method Details

AddValue() public méthode

Add value (or values) to current bucket.
public AddValue ( ) : void
Résultat void

GetMean() public méthode

Gets the mean (average) of all values in the current snapshot. This is not a percentile but often desired so captured and exposed here.
public GetMean ( ) : int
Résultat int

GetPercentile() public méthode

Compute a percentile from the underlying rolling buckets of values.

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 5000 milliseconds, then this method will re-compute a percentile at most once every 5000 milliseconds.

public GetPercentile ( double percentile ) : int
percentile double Value such as 99 (99th percentile), 99.5 (99.5th percentile), 50 (median, 50th percentile) to compute and retrieve percentile from rolling buckets.
Résultat int

HystrixRollingPercentile() public méthode

Initializes a new instance of the HystrixRollingPercentile class.
public HystrixRollingPercentile ( IHystrixProperty timeInMilliseconds, IHystrixProperty numberOfBuckets, IHystrixProperty bucketDataLength, IHystrixProperty enabled ) : System
timeInMilliseconds IHystrixProperty Number of milliseconds of data that should be tracked.
numberOfBuckets IHystrixProperty Number of buckets that the time window should be divided into.
bucketDataLength IHystrixProperty Number of values stored in each bucket.
enabled IHystrixProperty Sets whether data should be tracked and percentiles be calculated.
Résultat System

Reset() public méthode

Force a reset so that percentiles start being gathered from scratch.
public Reset ( ) : void
Résultat void