Documentation ¶
Index ¶
- Variables
- func MakeBucketsForError(error float64) []int64
- func RegistryHandler(reg Registry) http.Handler
- type Collection
- type Counter
- type CounterFunc
- type CounterMetric
- type CounterValue
- type Distribution
- func (d *Distribution) Count() uint64
- func (d *Distribution) MarshalJSON() ([]byte, error)
- func (d *Distribution) MarshalText() ([]byte, error)
- func (d *Distribution) Max() float64
- func (d *Distribution) Mean() float64
- func (d *Distribution) Min() float64
- func (d *Distribution) Reset()
- func (d *Distribution) StdDev() float64
- func (d *Distribution) String() string
- func (d *Distribution) Sum() float64
- func (d *Distribution) Update(value float64)
- func (d *Distribution) Value() DistributionValue
- func (d *Distribution) Variance() float64
- type DistributionMetric
- type DistributionValue
- type Doer
- type EWMA
- type EWMAGauge
- type FloatGaugeFunc
- type GaugeFunc
- type GaugeMetric
- type GaugeValue
- type Histogram
- func NewBiasedHistogram() Histogram
- func NewBucketedHistogram(bucketOffsets []int64) Histogram
- func NewDefaultBucketedHistogram() Histogram
- func NewDefaultMunroPatersonHistogram() Histogram
- func NewMunroPatersonHistogram(bufSize, maxDepth int) Histogram
- func NewMunroPatersonHistogramWithMaxMemory(bytes int) Histogram
- func NewMunroPatersonHistogramWithPrecision(p Precision) Histogram
- func NewSampledHistogram(sample Sample) Histogram
- func NewUnbiasedHistogram() Histogram
- type HistogramExport
- type IntegerGauge
- func (c *IntegerGauge) Dec(delta int64)
- func (c *IntegerGauge) Inc(delta int64)
- func (c *IntegerGauge) IntegerValue() int64
- func (c *IntegerGauge) MarshalJSON() ([]byte, error)
- func (c *IntegerGauge) MarshalText() ([]byte, error)
- func (c *IntegerGauge) Reset() int64
- func (c *IntegerGauge) Set(value int64)
- func (c *IntegerGauge) String() string
- func (c *IntegerGauge) Value() float64
- type Meter
- func (m *Meter) Count() uint64
- func (m *Meter) FifteenMinuteRate() float64
- func (m *Meter) FiveMinuteRate() float64
- func (m *Meter) MarshalJSON() ([]byte, error)
- func (m *Meter) MarshalText() ([]byte, error)
- func (m *Meter) MeanRate() float64
- func (m *Meter) OneMinuteRate() float64
- func (m *Meter) Stop()
- func (m *Meter) String() string
- func (m *Meter) Update(delta uint64)
- type NamedDistribution
- type NamedValue
- type Precision
- type Registry
- type RegistrySnapshot
- type Sample
Constants ¶
This section is empty.
Variables ¶
var ( // M1Alpha represents 1 minute at a 5 second interval M1Alpha = 1 - math.Exp(-5.0/60/1) // M5Alpha represents 5 minutes at a 5 second interval M5Alpha = 1 - math.Exp(-5.0/60/5) // M15Alpha represents 15 minutes at a 5 second interval M15Alpha = 1 - math.Exp(-5.0/60/15) )
var ( DefaultPercentiles = []float64{0.5, 0.75, 0.9, 0.99, 0.999} DefaultPercentileNames = []string{"p50", "p75", "p90", "p99", "p999"} )
var ( DefaultPrecision = Precision{0.02, 100 * 1000} DefaultMaxMemory = 12 * 1024 )
var RuntimeMetrics = &runtimeMetrics{}
Functions ¶
func MakeBucketsForError ¶
MakeBucketsForError compute all the bucket values from 1 until we run out of positive 64-bit ints for the given an error (+/-). The error should be in percent, between 0.0 and 1.0.
Each bucket's value will be the midpoint of an error range to the edge of the bucket in each direction, so for example, given a 5% error range (the default), the bucket with value N will cover numbers 5% smaller (0.95*N) and 5% larger (1.05*N).
For the usual default of 5%, this results in 200 buckets.
The last bucket (the "infinity" bucket) ranges up to math.MaxInt64, which we treat as infinity.
func RegistryHandler ¶
Types ¶
type Collection ¶
type Collection interface {
Metrics() map[string]interface{}
}
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
func NewCounter ¶
func NewCounter() *Counter
NewCounter returns a counter implemented as an atomic uint64.
func (*Counter) MarshaText ¶
func (*Counter) MarshalJSON ¶
type CounterFunc ¶
type CounterFunc func() uint64
func (CounterFunc) Count ¶
func (f CounterFunc) Count() uint64
type CounterMetric ¶
type CounterMetric interface {
Count() uint64
}
Counter is the interface for a counter metric.
type CounterValue ¶
type CounterValue uint64
func (CounterValue) Count ¶
func (v CounterValue) Count() uint64
type Distribution ¶
type Distribution struct {
// contains filtered or unexported fields
}
Distribution tracks the min, max, sum, count, and variance/stddev of a set of values.
func NewDistribution ¶
func NewDistribution() *Distribution
NewDistribution returns a new instance of a Distribution
func (*Distribution) Count ¶
func (d *Distribution) Count() uint64
Count returns the number of data points
func (*Distribution) MarshalJSON ¶
func (d *Distribution) MarshalJSON() ([]byte, error)
func (*Distribution) MarshalText ¶
func (d *Distribution) MarshalText() ([]byte, error)
func (*Distribution) Max ¶
func (d *Distribution) Max() float64
Max returns the maximum value of all data points
func (*Distribution) Mean ¶
func (d *Distribution) Mean() float64
Mean returns the average of all of all data points
func (*Distribution) Min ¶
func (d *Distribution) Min() float64
Min returns the minimum value of all data points
func (*Distribution) Reset ¶
func (d *Distribution) Reset()
Reset the distribution to its initial empty state.
func (*Distribution) StdDev ¶
func (d *Distribution) StdDev() float64
StdDev returns the standard deviation of all data points
func (*Distribution) String ¶
func (d *Distribution) String() string
func (*Distribution) Sum ¶
func (d *Distribution) Sum() float64
Sum returns the sum of all data points
func (*Distribution) Update ¶
func (d *Distribution) Update(value float64)
Update inserts a new data point
func (*Distribution) Value ¶
func (d *Distribution) Value() DistributionValue
func (*Distribution) Variance ¶
func (d *Distribution) Variance() float64
Variance returns the variance of all data points
type DistributionMetric ¶
type DistributionMetric interface {
Value() DistributionValue
}
type DistributionValue ¶
func (DistributionValue) Mean ¶
func (v DistributionValue) Mean() float64
type EWMA ¶
type EWMA struct {
// contains filtered or unexported fields
}
EWMA is an exponentially-weighted moving average.
http://www.teamquest.com/pdfs/whitepaper/ldavg1.pdf - UNIX Load Average Part 1: How It Works http://www.teamquest.com/pdfs/whitepaper/ldavg2.pdf - UNIX Load Average Part 2: Not Your Average Average
func (*EWMA) MarshalJSON ¶
func (*EWMA) MarshalText ¶
type EWMAGauge ¶
type EWMAGauge struct {
// contains filtered or unexported fields
}
func NewEWMAGauge ¶
func NewEWMAGauge(interval time.Duration, alpha float64, fun FloatGaugeFunc) *EWMAGauge
func (*EWMAGauge) MarshalJSON ¶
func (*EWMAGauge) MarshalText ¶
type FloatGaugeFunc ¶
type FloatGaugeFunc func() float64
FloatGaugeFunc is used for stats reporting to identify the value as a floating point gauge
type GaugeMetric ¶
type GaugeMetric interface {
Value() float64
}
type GaugeValue ¶
type GaugeValue float64
func (GaugeValue) Value ¶
func (v GaugeValue) Value() float64
type Histogram ¶
type Histogram interface { Clear() Update(int64) Distribution() DistributionValue Percentiles([]float64) []int64 String() string }
func NewBiasedHistogram ¶
func NewBiasedHistogram() Histogram
NewBiasedHistogram returns a histogram that uses an exponentially decaying sample of 1028 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution, and an alpha factor of 0.015, which heavily biases the sample to the past 5 minutes of measurements.
func NewBucketedHistogram ¶
NewBucketedHistogram returns a histogram that uses a fixed set of buckets for ranges of values. This is an implementation of the Histogram class from Ostrich. https://github.com/twitter/ostrich/blob/master/src/main/scala/com/twitter/ostrich/stats/Histogram.scala
func NewDefaultBucketedHistogram ¶
func NewDefaultBucketedHistogram() Histogram
NewDefaultBucketedHistogram returns a bucketed histogram with an error of 5%
func NewDefaultMunroPatersonHistogram ¶
func NewDefaultMunroPatersonHistogram() Histogram
func NewMunroPatersonHistogram ¶
NewMunroPatersonHistogram returns an implemenation of the Munro-Paterson approximate histogram algorithm adapted from: https://github.com/twitter/commons/blob/master/src/java/com/twitter/common/stats/ApproximateHistogram.java http://szl.googlecode.com/svn-history/r36/trunk/src/emitters/szlquantile.cc
func NewSampledHistogram ¶
func NewUnbiasedHistogram ¶
func NewUnbiasedHistogram() Histogram
NewUnbiasedHistogram returns a histogram that uses a uniform sample of 1028 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution.
type HistogramExport ¶
func (*HistogramExport) MarshalJSON ¶
func (e *HistogramExport) MarshalJSON() ([]byte, error)
func (*HistogramExport) MarshalText ¶
func (e *HistogramExport) MarshalText() ([]byte, error)
func (*HistogramExport) String ¶
func (e *HistogramExport) String() string
Return a JSON encoded version of the Histgram output
type IntegerGauge ¶
type IntegerGauge struct {
// contains filtered or unexported fields
}
func NewIntegerGauge ¶
func NewIntegerGauge() *IntegerGauge
func (*IntegerGauge) Dec ¶
func (c *IntegerGauge) Dec(delta int64)
func (*IntegerGauge) Inc ¶
func (c *IntegerGauge) Inc(delta int64)
func (*IntegerGauge) IntegerValue ¶
func (c *IntegerGauge) IntegerValue() int64
func (*IntegerGauge) MarshalJSON ¶
func (c *IntegerGauge) MarshalJSON() ([]byte, error)
func (*IntegerGauge) MarshalText ¶
func (c *IntegerGauge) MarshalText() ([]byte, error)
func (*IntegerGauge) Reset ¶
func (c *IntegerGauge) Reset() int64
func (*IntegerGauge) Set ¶
func (c *IntegerGauge) Set(value int64)
func (*IntegerGauge) String ¶
func (c *IntegerGauge) String() string
func (*IntegerGauge) Value ¶
func (c *IntegerGauge) Value() float64
type Meter ¶
type Meter struct {
// contains filtered or unexported fields
}
Meter is the combination of three EWMA metrics: 1 min, 5 min, and 15 min.
func (*Meter) FifteenMinuteRate ¶
FifteenMinuteRate returns the 15 minute EWMA rate
func (*Meter) FiveMinuteRate ¶
FiveMinuteRate returns the 5 minute EWMA rate
func (*Meter) MarshalJSON ¶
func (*Meter) MarshalText ¶
func (*Meter) OneMinuteRate ¶
OneMinuteRate returns the 1 minute EWMA rate
type NamedDistribution ¶
type NamedDistribution struct { Name string Value DistributionValue }
type NamedValue ¶
type Registry ¶
type Registry interface { Scope(scope string) Registry Add(name string, metric interface{}) Remove(name string) Do(f Doer) error }
func NewFilterdRegistry ¶
func NewRegistry ¶
func NewRegistry() Registry
type RegistrySnapshot ¶
type RegistrySnapshot struct { Values []NamedValue Distributions []NamedDistribution // contains filtered or unexported fields }
func NewRegistrySnapshot ¶
func NewRegistrySnapshot(resetOnSnapshot bool) *RegistrySnapshot
func (*RegistrySnapshot) Add ¶
func (rs *RegistrySnapshot) Add(name string, metric interface{})
func (*RegistrySnapshot) Do ¶
func (rs *RegistrySnapshot) Do(f Doer) error
func (*RegistrySnapshot) Remove ¶
func (rs *RegistrySnapshot) Remove(name string)
func (*RegistrySnapshot) Scope ¶
func (rs *RegistrySnapshot) Scope(scope string) Registry
func (*RegistrySnapshot) Snapshot ¶
func (rs *RegistrySnapshot) Snapshot(registry Registry)
type Sample ¶
func NewExponentiallyDecayingSample ¶
NewExponentiallyDecayingSample returns an exponentially-decaying random sample of values. Uses Cormode et al's forward-decaying priority reservoir sampling method to produce a statistically representative sample, exponentially biased towards newer entries.
http://www.research.att.com/people/Cormode_Graham/library/publications/CormodeShkapenyukSrivastavaXu09.pdf Cormode et al. Forward Decay: A Practical Time Decay Model for Streaming Systems. ICDE '09: Proceedings of the 2009 IEEE International Conference on Data Engineering (2009)
func NewExponentiallyDecayingSampleWithCustomTime ¶
func NewExponentiallyDecayingSampleWithCustomTime(reservoirSize int, alpha float64, now func() time.Time) Sample
NewExponentiallyDecayingSampleWithCustomTime returns an exponentially-decaying random sample of values using a custom time function.
func NewUniformSample ¶
NewUniformSample returns a sample randomly selects from a stream. Uses Vitter's Algorithm R to produce a statistically representative sample.
http://www.cs.umd.edu/~samir/498/vitter.pdf - Random Sampling with a Reservoir