Documentation ¶
Index ¶
- func CounterClock(c timetools.TimeProvider) rcOptSetter
- func RTClock(clock timetools.TimeProvider) rrOptSetter
- func RTCounter(new NewCounterFn) rrOptSetter
- func RTHistogram(new NewRollingHistogramFn) rrOptSetter
- func RatioClock(clock timetools.TimeProvider) ratioOptSetter
- func RollingClock(clock timetools.TimeProvider) rhOptSetter
- 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) 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) 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) 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 CounterClock ¶
func CounterClock(c timetools.TimeProvider) rcOptSetter
func RTClock ¶
func RTClock(clock timetools.TimeProvider) rrOptSetter
func RTCounter ¶
func RTCounter(new NewCounterFn) rrOptSetter
func RTHistogram ¶
func RTHistogram(new NewRollingHistogramFn) rrOptSetter
func RatioClock ¶
func RatioClock(clock timetools.TimeProvider) ratioOptSetter
func RollingClock ¶
func RollingClock(clock timetools.TimeProvider) rhOptSetter
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 essense 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)
SplitRatios 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/codahale/hdrhistogram that provides convenience functions for measuring http latencies
func NewHDRHistogram ¶
func NewHDRHistogram(low, high int64, sigfigs int) (h *HDRHistogram, err error)
func (*HDRHistogram) LatencyAtQuantile ¶
func (h *HDRHistogram) LatencyAtQuantile(q float64) time.Duration
Returns latency at quantile with microsecond precision
func (*HDRHistogram) Merge ¶
func (h *HDRHistogram) Merge(other *HDRHistogram) error
func (*HDRHistogram) RecordLatencies ¶
func (h *HDRHistogram) RecordLatencies(d time.Duration, n int64) error
Records latencies with microsecond precision
func (*HDRHistogram) RecordValues ¶
func (h *HDRHistogram) RecordValues(v, n int64) error
func (*HDRHistogram) Reset ¶
func (h *HDRHistogram) Reset()
func (*HDRHistogram) ValueAtQuantile ¶
func (h *HDRHistogram) ValueAtQuantile(q float64) int64
type NewCounterFn ¶
type NewCounterFn func() (*RollingCounter, error)
type NewRTMetricsFn ¶
type NewRollingHistogramFn ¶
type NewRollingHistogramFn func() (*RollingHDRHistogram, error)
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 ¶
func (*RTMetrics) LatencyHistogram ¶
func (m *RTMetrics) LatencyHistogram() (*HDRHistogram, error)
GetLatencyHistogram computes and returns resulting histogram with latencies observed.
func (*RTMetrics) NetworkErrorCount ¶
GetNetworkErrorCount returns total count of processed requests observed
func (*RTMetrics) NetworkErrorRatio ¶
GetNetworkErrorRatio calculates the amont of network errors such as time outs and dropped connection that occured in the given time window compared to the total requests count.
func (*RTMetrics) ResponseCodeRatio ¶
GetResponseCodeRatio calculates ratio of count(startA to endA) / count(startB to endB)
func (*RTMetrics) StatusCodesCounts ¶
GetStatusCodesCounts returns map with counts of the response codes
func (*RTMetrics) TotalCount ¶
GetTotalCount 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)
func (*RatioCounter) Buckets ¶
func (r *RatioCounter) Buckets() int
func (*RatioCounter) CountA ¶
func (r *RatioCounter) CountA() int64
func (*RatioCounter) CountB ¶
func (r *RatioCounter) CountB() int64
func (*RatioCounter) IncA ¶
func (r *RatioCounter) IncA(v int)
func (*RatioCounter) IncB ¶
func (r *RatioCounter) IncB(v int)
func (*RatioCounter) IsReady ¶
func (r *RatioCounter) IsReady() bool
func (*RatioCounter) ProcessedCount ¶
func (r *RatioCounter) ProcessedCount() int64
func (*RatioCounter) Ratio ¶
func (r *RatioCounter) Ratio() float64
func (*RatioCounter) Reset ¶
func (r *RatioCounter) Reset()
func (*RatioCounter) Resolution ¶
func (r *RatioCounter) Resolution() time.Duration
func (*RatioCounter) WindowSize ¶
func (r *RatioCounter) WindowSize() time.Duration
type RollingCounter ¶
type RollingCounter struct {
// contains filtered or unexported fields
}
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
func (*RollingCounter) Buckets ¶
func (c *RollingCounter) Buckets() int
func (*RollingCounter) Clone ¶
func (c *RollingCounter) Clone() *RollingCounter
func (*RollingCounter) Count ¶
func (c *RollingCounter) Count() int64
func (*RollingCounter) CountedBuckets ¶
func (c *RollingCounter) CountedBuckets() int
func (*RollingCounter) Inc ¶
func (c *RollingCounter) Inc(v int)
func (*RollingCounter) Reset ¶
func (c *RollingCounter) Reset()
func (*RollingCounter) Resolution ¶
func (c *RollingCounter) Resolution() time.Duration
func (*RollingCounter) WindowSize ¶
func (c *RollingCounter) WindowSize() time.Duration
type RollingHDRHistogram ¶
type RollingHDRHistogram struct {
// contains filtered or unexported fields
}
RollingHistogram holds multiple histograms and rotates every period. It provides resulting histogram as a result of a call of 'Merged' function.
func NewRollingHDRHistogram ¶
func (*RollingHDRHistogram) Append ¶
func (r *RollingHDRHistogram) Append(o *RollingHDRHistogram) error
func (*RollingHDRHistogram) Merged ¶
func (r *RollingHDRHistogram) Merged() (*HDRHistogram, error)
func (*RollingHDRHistogram) RecordLatencies ¶
func (r *RollingHDRHistogram) RecordLatencies(v time.Duration, n int64) error
func (*RollingHDRHistogram) RecordValues ¶
func (r *RollingHDRHistogram) RecordValues(v, n int64) error
func (*RollingHDRHistogram) Reset ¶
func (r *RollingHDRHistogram) Reset()