C# 클래스 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.

파일 보기 프로젝트 열기: Elders/Hystrix.NET 1 사용 예제들

Private Properties

프로퍼티 타입 설명
GetCurrentBucket Bucket
HystrixRollingPercentile System

공개 메소드들

메소드 설명
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.

비공개 메소드들

메소드 설명
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.

메소드 상세

AddValue() 공개 메소드

Add value (or values) to current bucket.
public AddValue ( ) : void
리턴 void

GetMean() 공개 메소드

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
리턴 int

GetPercentile() 공개 메소드

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.
리턴 int

HystrixRollingPercentile() 공개 메소드

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.
리턴 System

Reset() 공개 메소드

Force a reset so that percentiles start being gathered from scratch.
public Reset ( ) : void
리턴 void