Documentation ¶
Index ¶
- func RTCounter(fn NewCounterFn) rrOptSetter
- func RTHistogram(fn NewRollingHistogramFn) rrOptSetter
- func SplitFloat64(threshold, sentinel float64, values []float64) (good map[float64]bool, bad map[float64]bool)
- func SplitLatencies(values []time.Duration, precision time.Duration) (good map[time.Duration]bool, bad map[time.Duration]bool)
- func SplitRatios(values []float64) (good map[float64]bool, bad map[float64]bool)
- type HDRHistogram
- func (h *HDRHistogram) Export() *HDRHistogram
- func (h *HDRHistogram) LatencyAtQuantile(q float64) time.Duration
- func (h *HDRHistogram) Merge(other *HDRHistogram) error
- func (h *HDRHistogram) RecordLatencies(d time.Duration, n int64) error
- func (h *HDRHistogram) RecordValues(v, n int64) error
- func (h *HDRHistogram) Reset()
- func (h *HDRHistogram) ValueAtQuantile(q float64) int64
- type NewCounterFn
- type NewRTMetricsFn
- type NewRollingHistogramFn
- type RTMetrics
- func (m *RTMetrics) Append(other *RTMetrics) error
- func (m *RTMetrics) CounterWindowSize() time.Duration
- func (m *RTMetrics) Export() *RTMetrics
- func (m *RTMetrics) LatencyHistogram() (*HDRHistogram, error)
- func (m *RTMetrics) NetworkErrorCount() int64
- func (m *RTMetrics) NetworkErrorRatio() float64
- func (m *RTMetrics) Record(code int, duration time.Duration)
- func (m *RTMetrics) Reset()
- func (m *RTMetrics) ResponseCodeRatio(startA, endA, startB, endB int) float64
- func (m *RTMetrics) StatusCodesCounts() map[int]int64
- func (m *RTMetrics) TotalCount() int64
- type RatioCounter
- func (r *RatioCounter) Buckets() int
- func (r *RatioCounter) CountA() int64
- func (r *RatioCounter) CountB() int64
- func (r *RatioCounter) IncA(v int)
- func (r *RatioCounter) IncB(v int)
- func (r *RatioCounter) IsReady() bool
- func (r *RatioCounter) ProcessedCount() int64
- func (r *RatioCounter) Ratio() float64
- func (r *RatioCounter) Reset()
- func (r *RatioCounter) Resolution() time.Duration
- func (r *RatioCounter) WindowSize() time.Duration
- type RollingCounter
- func (c *RollingCounter) Append(o *RollingCounter) error
- func (c *RollingCounter) Buckets() int
- func (c *RollingCounter) Clone() *RollingCounter
- func (c *RollingCounter) Count() int64
- func (c *RollingCounter) CountedBuckets() int
- func (c *RollingCounter) Inc(v int)
- func (c *RollingCounter) Reset()
- func (c *RollingCounter) Resolution() time.Duration
- func (c *RollingCounter) WindowSize() time.Duration
- type RollingHDRHistogram
- func (r *RollingHDRHistogram) Append(o *RollingHDRHistogram) error
- func (r *RollingHDRHistogram) Export() *RollingHDRHistogram
- func (r *RollingHDRHistogram) Merged() (*HDRHistogram, error)
- func (r *RollingHDRHistogram) RecordLatencies(v time.Duration, n int64) error
- func (r *RollingHDRHistogram) RecordValues(v, n int64) error
- func (r *RollingHDRHistogram) Reset()
- type TestMeter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RTCounter ¶
func RTCounter(fn NewCounterFn) rrOptSetter
RTCounter set a builder function for Counter.
func RTHistogram ¶
func RTHistogram(fn NewRollingHistogramFn) rrOptSetter
RTHistogram set a builder function for RollingHistogram.
func SplitFloat64 ¶
func SplitFloat64(threshold, sentinel float64, values []float64) (good map[float64]bool, bad map[float64]bool)
SplitFloat64 provides simple anomaly detection for skewed data sets with no particular distribution. In essence it applies the formula if(v > median(values) + threshold * medianAbsoluteDeviation) -> anomaly There's a corner case where there are just 2 values, so by definition there's no value that exceeds the threshold. This case is solved by introducing additional value that we know is good, e.g. 0. That helps to improve the detection results on such data sets.
func SplitLatencies ¶
func SplitLatencies(values []time.Duration, precision time.Duration) (good map[time.Duration]bool, bad map[time.Duration]bool)
SplitLatencies provides simple anomaly detection for requests latencies. it splits values into good or bad category based on the threshold and the median value. If all values are not far from the median, it will return all values in 'good' set. Precision is the smallest value to consider, e.g. if set to millisecond, microseconds will be ignored.
func SplitRatios ¶
SplitRatios provides simple anomaly detection for ratio values, that are all in the range [0, 1] it splits values into good or bad category based on the threshold and the median value. If all values are not far from the median, it will return all values in 'good' set.
Types ¶
type HDRHistogram ¶
type HDRHistogram struct {
// contains filtered or unexported fields
}
HDRHistogram is a tiny wrapper around github.com/HdrHistogram/hdrhistogram-go that provides convenience functions for measuring http latencies.
func NewHDRHistogram ¶
func NewHDRHistogram(low, high int64, sigfigs int) (h *HDRHistogram, err error)
NewHDRHistogram creates a new HDRHistogram.
func (*HDRHistogram) Export ¶
func (h *HDRHistogram) Export() *HDRHistogram
Export export a HDRHistogram.
func (*HDRHistogram) LatencyAtQuantile ¶
func (h *HDRHistogram) LatencyAtQuantile(q float64) time.Duration
LatencyAtQuantile sets latency at quantile with microsecond precision.
func (*HDRHistogram) Merge ¶
func (h *HDRHistogram) Merge(other *HDRHistogram) error
Merge merge a HDRHistogram.
func (*HDRHistogram) RecordLatencies ¶
func (h *HDRHistogram) RecordLatencies(d time.Duration, n int64) error
RecordLatencies Records latencies with microsecond precision.
func (*HDRHistogram) RecordValues ¶
func (h *HDRHistogram) RecordValues(v, n int64) error
RecordValues sets record values.
func (*HDRHistogram) ValueAtQuantile ¶
func (h *HDRHistogram) ValueAtQuantile(q float64) int64
ValueAtQuantile sets value at quantile.
type NewCounterFn ¶
type NewCounterFn func() (*RollingCounter, error)
NewCounterFn builder function type.
type NewRTMetricsFn ¶
NewRTMetricsFn builder function type.
type NewRollingHistogramFn ¶
type NewRollingHistogramFn func() (*RollingHDRHistogram, error)
NewRollingHistogramFn builder function type.
type RTMetrics ¶
type RTMetrics struct {
// contains filtered or unexported fields
}
RTMetrics provides aggregated performance metrics for HTTP requests processing such as round trip latency, response codes counters network error and total requests. all counters are collected as rolling window counters with defined precision, histograms are a rolling window histograms with defined precision as well. See RTOptions for more detail on parameters.
func NewRTMetrics ¶
NewRTMetrics returns new instance of metrics collector.
func (*RTMetrics) CounterWindowSize ¶
CounterWindowSize gets total windows size.
func (*RTMetrics) LatencyHistogram ¶
func (m *RTMetrics) LatencyHistogram() (*HDRHistogram, error)
LatencyHistogram computes and returns resulting histogram with latencies observed.
func (*RTMetrics) NetworkErrorCount ¶
NetworkErrorCount returns total count of processed requests observed.
func (*RTMetrics) NetworkErrorRatio ¶
NetworkErrorRatio calculates the amont of network errors such as time outs and dropped connection that occurred in the given time window compared to the total requests count.
func (*RTMetrics) ResponseCodeRatio ¶
ResponseCodeRatio calculates ratio of count(startA to endA) / count(startB to endB).
func (*RTMetrics) StatusCodesCounts ¶
StatusCodesCounts returns map with counts of the response codes.
func (*RTMetrics) TotalCount ¶
TotalCount returns total count of processed requests collected.
type RatioCounter ¶
type RatioCounter struct {
// contains filtered or unexported fields
}
RatioCounter calculates a ratio of a/a+b over a rolling window of predefined buckets.
func NewRatioCounter ¶
func NewRatioCounter(buckets int, resolution time.Duration, options ...ratioOptSetter) (*RatioCounter, error)
NewRatioCounter creates a new RatioCounter.
func (*RatioCounter) IsReady ¶
func (r *RatioCounter) IsReady() bool
IsReady returns true if the counter is ready.
func (*RatioCounter) ProcessedCount ¶
func (r *RatioCounter) ProcessedCount() int64
ProcessedCount gets processed count.
func (*RatioCounter) Resolution ¶
func (r *RatioCounter) Resolution() time.Duration
Resolution gets resolution.
func (*RatioCounter) WindowSize ¶
func (r *RatioCounter) WindowSize() time.Duration
WindowSize gets windows size.
type RollingCounter ¶
type RollingCounter struct {
// contains filtered or unexported fields
}
RollingCounter Calculates in memory failure rate of an endpoint using rolling window of a predefined size.
func NewCounter ¶
func NewCounter(buckets int, resolution time.Duration, options ...rcOptSetter) (*RollingCounter, error)
NewCounter creates a counter with fixed amount of buckets that are rotated every resolution period. E.g. 10 buckets with 1 second means that every new second the bucket is refreshed, so it maintains 10 second rolling window. By default creates a bucket with 10 buckets and 1 second resolution.
func (*RollingCounter) Append ¶
func (c *RollingCounter) Append(o *RollingCounter) error
Append append a counter.
func (*RollingCounter) Clone ¶
func (c *RollingCounter) Clone() *RollingCounter
Clone clone a counter.
func (*RollingCounter) CountedBuckets ¶
func (c *RollingCounter) CountedBuckets() int
CountedBuckets gets counted buckets.
func (*RollingCounter) Resolution ¶
func (c *RollingCounter) Resolution() time.Duration
Resolution gets resolution.
func (*RollingCounter) WindowSize ¶
func (c *RollingCounter) WindowSize() time.Duration
WindowSize gets windows size.
type RollingHDRHistogram ¶
type RollingHDRHistogram struct {
// contains filtered or unexported fields
}
RollingHDRHistogram holds multiple histograms and rotates every period. It provides resulting histogram as a result of a call of 'Merged' function.
func NewRollingHDRHistogram ¶
func NewRollingHDRHistogram(low, high int64, sigfigs int, period time.Duration, bucketCount int, options ...rhOptSetter) (*RollingHDRHistogram, error)
NewRollingHDRHistogram created a new RollingHDRHistogram.
func (*RollingHDRHistogram) Append ¶
func (r *RollingHDRHistogram) Append(o *RollingHDRHistogram) error
Append append a RollingHDRHistogram.
func (*RollingHDRHistogram) Export ¶
func (r *RollingHDRHistogram) Export() *RollingHDRHistogram
Export export a RollingHDRHistogram.
func (*RollingHDRHistogram) Merged ¶
func (r *RollingHDRHistogram) Merged() (*HDRHistogram, error)
Merged gets merged histogram.
func (*RollingHDRHistogram) RecordLatencies ¶
func (r *RollingHDRHistogram) RecordLatencies(v time.Duration, n int64) error
RecordLatencies sets records latencies.
func (*RollingHDRHistogram) RecordValues ¶
func (r *RollingHDRHistogram) RecordValues(v, n int64) error
RecordValues set record values.
func (*RollingHDRHistogram) Reset ¶
func (r *RollingHDRHistogram) Reset()
Reset reset a RollingHDRHistogram.
type TestMeter ¶
TestMeter a test meter.
func (*TestMeter) GetWindowSize ¶
GetWindowSize gets windows size.