memmetrics

package
v0.8.0-beta.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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

func SplitRatios(values []float64) (good map[float64]bool, bad map[float64]bool)

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 NewRTMetricsFn func() (*RTMetrics, error)

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

func NewRTMetrics(settings ...rrOptSetter) (*RTMetrics, error)

NewRTMetrics returns new instance of metrics collector.

func (*RTMetrics) Append

func (m *RTMetrics) Append(other *RTMetrics) error

func (*RTMetrics) CounterWindowSize

func (m *RTMetrics) CounterWindowSize() time.Duration

func (*RTMetrics) LatencyHistogram

func (m *RTMetrics) LatencyHistogram() (*HDRHistogram, error)

GetLatencyHistogram computes and returns resulting histogram with latencies observed.

func (*RTMetrics) NetworkErrorCount

func (m *RTMetrics) NetworkErrorCount() int64

GetNetworkErrorCount returns total count of processed requests observed

func (*RTMetrics) NetworkErrorRatio

func (m *RTMetrics) NetworkErrorRatio() float64

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) Record

func (m *RTMetrics) Record(code int, duration time.Duration)

func (*RTMetrics) Reset

func (m *RTMetrics) Reset()

func (*RTMetrics) ResponseCodeRatio

func (m *RTMetrics) ResponseCodeRatio(startA, endA, startB, endB int) float64

GetResponseCodeRatio calculates ratio of count(startA to endA) / count(startB to endB)

func (*RTMetrics) StatusCodesCounts

func (m *RTMetrics) StatusCodesCounts() map[int]int64

GetStatusCodesCounts returns map with counts of the response codes

func (*RTMetrics) TotalCount

func (m *RTMetrics) TotalCount() int64

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 NewRollingHDRHistogram(low, high int64, sigfigs int, period time.Duration, bucketCount int, options ...rhOptSetter) (*RollingHDRHistogram, error)

func (*RollingHDRHistogram) Append

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()

type TestMeter

type TestMeter struct {
	Rate       float64
	NotReady   bool
	WindowSize time.Duration
}

func (*TestMeter) GetRate

func (tm *TestMeter) GetRate() float64

func (*TestMeter) GetWindowSize

func (tm *TestMeter) GetWindowSize() time.Duration

func (*TestMeter) IsReady

func (tm *TestMeter) IsReady() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL