metrics

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2016 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	M_Instance_Start                  Counter
	M_Page_Status_200                 Counter
	M_Page_Status_500                 Counter
	M_Page_Status_404                 Counter
	M_Api_Status_500                  Counter
	M_Api_Status_404                  Counter
	M_Api_User_SignUpStarted          Counter
	M_Api_User_SignUpCompleted        Counter
	M_Api_User_SignUpInvite           Counter
	M_Api_Dashboard_Save              Timer
	M_Api_Dashboard_Get               Timer
	M_Api_Dashboard_Search            Timer
	M_Api_Admin_User_Create           Counter
	M_Api_Login_Post                  Counter
	M_Api_Login_OAuth                 Counter
	M_Api_Org_Create                  Counter
	M_Api_Dashboard_Snapshot_Create   Counter
	M_Api_Dashboard_Snapshot_External Counter
	M_Api_Dashboard_Snapshot_Get      Counter
	M_Models_Dashboard_Insert         Counter

	// Timers
	M_DataSource_ProxyReq_Timer Timer
)
View Source
var UseNilMetrics bool

Functions

func Init added in v3.1.0

func Init()

func SampleMax added in v3.1.0

func SampleMax(values []int64) int64

SampleMax returns the maximum value of the slice of int64.

func SampleMean added in v3.1.0

func SampleMean(values []int64) float64

SampleMean returns the mean value of the slice of int64.

func SampleMin added in v3.1.0

func SampleMin(values []int64) int64

SampleMin returns the minimum value of the slice of int64.

func SamplePercentile added in v3.1.0

func SamplePercentile(values int64Slice, p float64) float64

SamplePercentiles returns an arbitrary percentile of the slice of int64.

func SamplePercentiles added in v3.1.0

func SamplePercentiles(values int64Slice, ps []float64) []float64

SamplePercentiles returns a slice of arbitrary percentiles of the slice of int64.

func SampleStdDev added in v3.1.0

func SampleStdDev(values []int64) float64

SampleStdDev returns the standard deviation of the slice of int64.

func SampleSum added in v3.1.0

func SampleSum(values []int64) int64

SampleSum returns the sum of the slice of int64.

func SampleVariance added in v3.1.0

func SampleVariance(values []int64) float64

SampleVariance returns the variance of the slice of int64.

Types

type Counter

type Counter interface {
	Metric

	Clear()
	Count() int64
	Dec(int64)
	Inc(int64)
}

Counters hold an int64 value that can be incremented and decremented.

func NewCounter

func NewCounter(meta *MetricMeta) Counter

NewCounter constructs a new StandardCounter.

func RegCounter added in v3.1.0

func RegCounter(name string, tagStrings ...string) Counter

type EWMA added in v3.1.0

type EWMA interface {
	Rate() float64
	Snapshot() EWMA
	Tick()
	Update(int64)
}

EWMAs continuously calculate an exponentially-weighted moving average based on an outside source of clock ticks.

func NewEWMA added in v3.1.0

func NewEWMA(alpha float64) EWMA

NewEWMA constructs a new EWMA with the given alpha.

func NewEWMA1 added in v3.1.0

func NewEWMA1() EWMA

NewEWMA1 constructs a new EWMA for a one-minute moving average.

func NewEWMA15 added in v3.1.0

func NewEWMA15() EWMA

NewEWMA15 constructs a new EWMA for a fifteen-minute moving average.

func NewEWMA5 added in v3.1.0

func NewEWMA5() EWMA

NewEWMA5 constructs a new EWMA for a five-minute moving average.

type EWMASnapshot added in v3.1.0

type EWMASnapshot float64

EWMASnapshot is a read-only copy of another EWMA.

func (EWMASnapshot) Rate added in v3.1.0

func (a EWMASnapshot) Rate() float64

Rate returns the rate of events per second at the time the snapshot was taken.

func (EWMASnapshot) Snapshot added in v3.1.0

func (a EWMASnapshot) Snapshot() EWMA

Snapshot returns the snapshot.

func (EWMASnapshot) Tick added in v3.1.0

func (EWMASnapshot) Tick()

Tick panics.

func (EWMASnapshot) Update added in v3.1.0

func (EWMASnapshot) Update(int64)

Update panics.

type ExpDecaySample added in v3.1.0

type ExpDecaySample struct {
	// contains filtered or unexported fields
}

ExpDecaySample is an exponentially-decaying sample using a forward-decaying priority reservoir. See Cormode et al's "Forward Decay: A Practical Time Decay Model for Streaming Systems".

<http://www.research.att.com/people/Cormode_Graham/library/publications/CormodeShkapenyukSrivastavaXu09.pdf>

func (*ExpDecaySample) Clear added in v3.1.0

func (s *ExpDecaySample) Clear()

Clear clears all samples.

func (*ExpDecaySample) Count added in v3.1.0

func (s *ExpDecaySample) Count() int64

Count returns the number of samples recorded, which may exceed the reservoir size.

func (*ExpDecaySample) Max added in v3.1.0

func (s *ExpDecaySample) Max() int64

Max returns the maximum value in the sample, which may not be the maximum value ever to be part of the sample.

func (*ExpDecaySample) Mean added in v3.1.0

func (s *ExpDecaySample) Mean() float64

Mean returns the mean of the values in the sample.

func (*ExpDecaySample) Min added in v3.1.0

func (s *ExpDecaySample) Min() int64

Min returns the minimum value in the sample, which may not be the minimum value ever to be part of the sample.

func (*ExpDecaySample) Percentile added in v3.1.0

func (s *ExpDecaySample) Percentile(p float64) float64

Percentile returns an arbitrary percentile of values in the sample.

func (*ExpDecaySample) Percentiles added in v3.1.0

func (s *ExpDecaySample) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of values in the sample.

func (*ExpDecaySample) Size added in v3.1.0

func (s *ExpDecaySample) Size() int

Size returns the size of the sample, which is at most the reservoir size.

func (*ExpDecaySample) Snapshot added in v3.1.0

func (s *ExpDecaySample) Snapshot() Sample

Snapshot returns a read-only copy of the sample.

func (*ExpDecaySample) StdDev added in v3.1.0

func (s *ExpDecaySample) StdDev() float64

StdDev returns the standard deviation of the values in the sample.

func (*ExpDecaySample) Sum added in v3.1.0

func (s *ExpDecaySample) Sum() int64

Sum returns the sum of the values in the sample.

func (*ExpDecaySample) Update added in v3.1.0

func (s *ExpDecaySample) Update(v int64)

Update samples a new value.

func (*ExpDecaySample) Values added in v3.1.0

func (s *ExpDecaySample) Values() []int64

Values returns a copy of the values in the sample.

func (*ExpDecaySample) Variance added in v3.1.0

func (s *ExpDecaySample) Variance() float64

Variance returns the variance of the values in the sample.

type Gauge added in v3.1.0

type Gauge interface {
	Metric

	Update(int64)
	Value() int64
}

Gauges hold an int64 value that can be set arbitrarily.

func NewGauge added in v3.1.0

func NewGauge(meta *MetricMeta) Gauge

func RegGauge added in v3.1.0

func RegGauge(meta *MetricMeta) Gauge

type GaugeSnapshot added in v3.1.0

type GaugeSnapshot struct {
	*MetricMeta
	// contains filtered or unexported fields
}

GaugeSnapshot is a read-only copy of another Gauge.

func (GaugeSnapshot) Snapshot added in v3.1.0

func (g GaugeSnapshot) Snapshot() Metric

Snapshot returns the snapshot.

func (GaugeSnapshot) Update added in v3.1.0

func (GaugeSnapshot) Update(int64)

Update panics.

func (GaugeSnapshot) Value added in v3.1.0

func (g GaugeSnapshot) Value() int64

Value returns the value at the time the snapshot was taken.

type GraphitePublisher added in v3.1.0

type GraphitePublisher struct {
	// contains filtered or unexported fields
}

func CreateGraphitePublisher added in v3.1.0

func CreateGraphitePublisher() (*GraphitePublisher, error)

func (*GraphitePublisher) Publish added in v3.1.0

func (this *GraphitePublisher) Publish(metrics []Metric)

type Histogram added in v3.1.0

type Histogram interface {
	Metric

	Clear()
	Count() int64
	Max() int64
	Mean() float64
	Min() int64
	Percentile(float64) float64
	Percentiles([]float64) []float64
	StdDev() float64
	Sum() int64
	Update(int64)
	Variance() float64
}

Histograms calculate distribution statistics from a series of int64 values.

func NewHistogram added in v3.1.0

func NewHistogram(meta *MetricMeta, s Sample) Histogram

type HistogramSnapshot added in v3.1.0

type HistogramSnapshot struct {
	*MetricMeta
	// contains filtered or unexported fields
}

HistogramSnapshot is a read-only copy of another Histogram.

func (*HistogramSnapshot) Clear added in v3.1.0

func (*HistogramSnapshot) Clear()

Clear panics.

func (*HistogramSnapshot) Count added in v3.1.0

func (h *HistogramSnapshot) Count() int64

Count returns the number of samples recorded at the time the snapshot was taken.

func (*HistogramSnapshot) Max added in v3.1.0

func (h *HistogramSnapshot) Max() int64

Max returns the maximum value in the sample at the time the snapshot was taken.

func (*HistogramSnapshot) Mean added in v3.1.0

func (h *HistogramSnapshot) Mean() float64

Mean returns the mean of the values in the sample at the time the snapshot was taken.

func (*HistogramSnapshot) Min added in v3.1.0

func (h *HistogramSnapshot) Min() int64

Min returns the minimum value in the sample at the time the snapshot was taken.

func (*HistogramSnapshot) Percentile added in v3.1.0

func (h *HistogramSnapshot) Percentile(p float64) float64

Percentile returns an arbitrary percentile of values in the sample at the time the snapshot was taken.

func (*HistogramSnapshot) Percentiles added in v3.1.0

func (h *HistogramSnapshot) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of values in the sample at the time the snapshot was taken.

func (*HistogramSnapshot) Sample added in v3.1.0

func (h *HistogramSnapshot) Sample() Sample

Sample returns the Sample underlying the histogram.

func (*HistogramSnapshot) Snapshot added in v3.1.0

func (h *HistogramSnapshot) Snapshot() Metric

Snapshot returns the snapshot.

func (*HistogramSnapshot) StdDev added in v3.1.0

func (h *HistogramSnapshot) StdDev() float64

StdDev returns the standard deviation of the values in the sample at the time the snapshot was taken.

func (*HistogramSnapshot) Sum added in v3.1.0

func (h *HistogramSnapshot) Sum() int64

Sum returns the sum in the sample at the time the snapshot was taken.

func (*HistogramSnapshot) Update added in v3.1.0

func (*HistogramSnapshot) Update(int64)

Update panics.

func (*HistogramSnapshot) Variance added in v3.1.0

func (h *HistogramSnapshot) Variance() float64

Variance returns the variance of inputs at the time the snapshot was taken.

type Meter added in v3.1.0

type Meter interface {
	Metric

	Count() int64
	Mark(int64)
	Rate1() float64
	Rate5() float64
	Rate15() float64
	RateMean() float64
}

Meters count events to produce exponentially-weighted moving average rates at one-, five-, and fifteen-minutes and a mean rate.

func NewMeter added in v3.1.0

func NewMeter(meta *MetricMeta) Meter

NewMeter constructs a new StandardMeter and launches a goroutine.

type MeterSnapshot added in v3.1.0

type MeterSnapshot struct {
	*MetricMeta
	// contains filtered or unexported fields
}

func (*MeterSnapshot) Count added in v3.1.0

func (m *MeterSnapshot) Count() int64

Count returns the count of events at the time the snapshot was taken.

func (*MeterSnapshot) Mark added in v3.1.0

func (*MeterSnapshot) Mark(n int64)

Mark panics.

func (*MeterSnapshot) Rate1 added in v3.1.0

func (m *MeterSnapshot) Rate1() float64

Rate1 returns the one-minute moving average rate of events per second at the time the snapshot was taken.

func (*MeterSnapshot) Rate15 added in v3.1.0

func (m *MeterSnapshot) Rate15() float64

Rate15 returns the fifteen-minute moving average rate of events per second at the time the snapshot was taken.

func (*MeterSnapshot) Rate5 added in v3.1.0

func (m *MeterSnapshot) Rate5() float64

Rate5 returns the five-minute moving average rate of events per second at the time the snapshot was taken.

func (*MeterSnapshot) RateMean added in v3.1.0

func (m *MeterSnapshot) RateMean() float64

RateMean returns the meter's mean rate of events per second at the time the snapshot was taken.

func (*MeterSnapshot) Snapshot added in v3.1.0

func (m *MeterSnapshot) Snapshot() Metric

Snapshot returns the snapshot.

type Metric added in v3.1.0

type Metric interface {
	Name() string
	GetTagsCopy() map[string]string
	StringifyTags() string
	Snapshot() Metric
}

type MetricMeta added in v3.1.0

type MetricMeta struct {
	// contains filtered or unexported fields
}

func NewMetricMeta added in v3.1.0

func NewMetricMeta(name string, tagStrings []string) *MetricMeta

func (*MetricMeta) GetTagsCopy added in v3.1.0

func (m *MetricMeta) GetTagsCopy() map[string]string

func (*MetricMeta) Name added in v3.1.0

func (m *MetricMeta) Name() string

func (*MetricMeta) StringifyTags added in v3.1.0

func (m *MetricMeta) StringifyTags() string

type MetricPublisher added in v3.1.0

type MetricPublisher interface {
	Publish(metrics []Metric)
}

type MetricSettings added in v3.1.0

type MetricSettings struct {
	Enabled         bool
	IntervalSeconds int64

	Publishers []MetricPublisher
}

type NilEWMA added in v3.1.0

type NilEWMA struct{}

NilEWMA is a no-op EWMA.

func (NilEWMA) Rate added in v3.1.0

func (NilEWMA) Rate() float64

Rate is a no-op.

func (NilEWMA) Snapshot added in v3.1.0

func (NilEWMA) Snapshot() EWMA

Snapshot is a no-op.

func (NilEWMA) Tick added in v3.1.0

func (NilEWMA) Tick()

Tick is a no-op.

func (NilEWMA) Update added in v3.1.0

func (NilEWMA) Update(n int64)

Update is a no-op.

type NilGauge added in v3.1.0

type NilGauge struct{ *MetricMeta }

NilGauge is a no-op Gauge.

func (NilGauge) Snapshot added in v3.1.0

func (NilGauge) Snapshot() Metric

Snapshot is a no-op.

func (NilGauge) Update added in v3.1.0

func (NilGauge) Update(v int64)

Update is a no-op.

func (NilGauge) Value added in v3.1.0

func (NilGauge) Value() int64

Value is a no-op.

type NilHistogram added in v3.1.0

type NilHistogram struct {
	*MetricMeta
}

NilHistogram is a no-op Histogram.

func (NilHistogram) Clear added in v3.1.0

func (NilHistogram) Clear()

Clear is a no-op.

func (NilHistogram) Count added in v3.1.0

func (NilHistogram) Count() int64

Count is a no-op.

func (NilHistogram) Max added in v3.1.0

func (NilHistogram) Max() int64

Max is a no-op.

func (NilHistogram) Mean added in v3.1.0

func (NilHistogram) Mean() float64

Mean is a no-op.

func (NilHistogram) Min added in v3.1.0

func (NilHistogram) Min() int64

Min is a no-op.

func (NilHistogram) Percentile added in v3.1.0

func (NilHistogram) Percentile(p float64) float64

Percentile is a no-op.

func (NilHistogram) Percentiles added in v3.1.0

func (NilHistogram) Percentiles(ps []float64) []float64

Percentiles is a no-op.

func (NilHistogram) Sample added in v3.1.0

func (NilHistogram) Sample() Sample

Sample is a no-op.

func (NilHistogram) Snapshot added in v3.1.0

func (n NilHistogram) Snapshot() Metric

Snapshot is a no-op.

func (NilHistogram) StdDev added in v3.1.0

func (NilHistogram) StdDev() float64

StdDev is a no-op.

func (NilHistogram) Sum added in v3.1.0

func (NilHistogram) Sum() int64

Sum is a no-op.

func (NilHistogram) Update added in v3.1.0

func (NilHistogram) Update(v int64)

Update is a no-op.

func (NilHistogram) Variance added in v3.1.0

func (NilHistogram) Variance() float64

Variance is a no-op.

type NilMeter added in v3.1.0

type NilMeter struct{ *MetricMeta }

NilMeter is a no-op Meter.

func (NilMeter) Count added in v3.1.0

func (NilMeter) Count() int64

Count is a no-op.

func (NilMeter) Mark added in v3.1.0

func (NilMeter) Mark(n int64)

Mark is a no-op.

func (NilMeter) Rate1 added in v3.1.0

func (NilMeter) Rate1() float64

Rate1 is a no-op.

func (NilMeter) Rate15 added in v3.1.0

func (NilMeter) Rate15() float64

Rate15is a no-op.

func (NilMeter) Rate5 added in v3.1.0

func (NilMeter) Rate5() float64

Rate5 is a no-op.

func (NilMeter) RateMean added in v3.1.0

func (NilMeter) RateMean() float64

RateMean is a no-op.

func (NilMeter) Snapshot added in v3.1.0

func (NilMeter) Snapshot() Metric

Snapshot is a no-op.

type NilSample added in v3.1.0

type NilSample struct{}

NilSample is a no-op Sample.

func (NilSample) Clear added in v3.1.0

func (NilSample) Clear()

Clear is a no-op.

func (NilSample) Count added in v3.1.0

func (NilSample) Count() int64

Count is a no-op.

func (NilSample) Max added in v3.1.0

func (NilSample) Max() int64

Max is a no-op.

func (NilSample) Mean added in v3.1.0

func (NilSample) Mean() float64

Mean is a no-op.

func (NilSample) Min added in v3.1.0

func (NilSample) Min() int64

Min is a no-op.

func (NilSample) Percentile added in v3.1.0

func (NilSample) Percentile(p float64) float64

Percentile is a no-op.

func (NilSample) Percentiles added in v3.1.0

func (NilSample) Percentiles(ps []float64) []float64

Percentiles is a no-op.

func (NilSample) Size added in v3.1.0

func (NilSample) Size() int

Size is a no-op.

func (NilSample) Snapshot added in v3.1.0

func (NilSample) Snapshot() Sample

Sample is a no-op.

func (NilSample) StdDev added in v3.1.0

func (NilSample) StdDev() float64

StdDev is a no-op.

func (NilSample) Sum added in v3.1.0

func (NilSample) Sum() int64

Sum is a no-op.

func (NilSample) Update added in v3.1.0

func (NilSample) Update(v int64)

Update is a no-op.

func (NilSample) Values added in v3.1.0

func (NilSample) Values() []int64

Values is a no-op.

func (NilSample) Variance added in v3.1.0

func (NilSample) Variance() float64

Variance is a no-op.

type NilTimer added in v3.1.0

type NilTimer struct {
	*MetricMeta
	// contains filtered or unexported fields
}

NilTimer is a no-op Timer.

func (NilTimer) Count added in v3.1.0

func (NilTimer) Count() int64

Count is a no-op.

func (NilTimer) Max added in v3.1.0

func (NilTimer) Max() int64

Max is a no-op.

func (NilTimer) Mean added in v3.1.0

func (NilTimer) Mean() float64

Mean is a no-op.

func (NilTimer) Min added in v3.1.0

func (NilTimer) Min() int64

Min is a no-op.

func (NilTimer) Percentile added in v3.1.0

func (NilTimer) Percentile(p float64) float64

Percentile is a no-op.

func (NilTimer) Percentiles added in v3.1.0

func (NilTimer) Percentiles(ps []float64) []float64

Percentiles is a no-op.

func (NilTimer) Rate1 added in v3.1.0

func (NilTimer) Rate1() float64

Rate1 is a no-op.

func (NilTimer) Rate15 added in v3.1.0

func (NilTimer) Rate15() float64

Rate15 is a no-op.

func (NilTimer) Rate5 added in v3.1.0

func (NilTimer) Rate5() float64

Rate5 is a no-op.

func (NilTimer) RateMean added in v3.1.0

func (NilTimer) RateMean() float64

RateMean is a no-op.

func (NilTimer) Snapshot added in v3.1.0

func (n NilTimer) Snapshot() Metric

Snapshot is a no-op.

func (NilTimer) StdDev added in v3.1.0

func (NilTimer) StdDev() float64

StdDev is a no-op.

func (NilTimer) Sum added in v3.1.0

func (NilTimer) Sum() int64

Sum is a no-op.

func (NilTimer) Time added in v3.1.0

func (NilTimer) Time(func())

Time is a no-op.

func (NilTimer) Update added in v3.1.0

func (NilTimer) Update(time.Duration)

Update is a no-op.

func (NilTimer) UpdateSince added in v3.1.0

func (NilTimer) UpdateSince(time.Time)

UpdateSince is a no-op.

func (NilTimer) Variance added in v3.1.0

func (NilTimer) Variance() float64

Variance is a no-op.

type Registry

type Registry interface {
	GetSnapshots() []Metric
	Register(metric Metric)
}
var MetricStats Registry

func NewRegistry

func NewRegistry() Registry

Create a new registry.

type Sample added in v3.1.0

type Sample interface {
	Clear()
	Count() int64
	Max() int64
	Mean() float64
	Min() int64
	Percentile(float64) float64
	Percentiles([]float64) []float64
	Size() int
	Snapshot() Sample
	StdDev() float64
	Sum() int64
	Update(int64)
	Values() []int64
	Variance() float64
}

Samples maintain a statistically-significant selection of values from a stream.

func NewExpDecaySample added in v3.1.0

func NewExpDecaySample(reservoirSize int, alpha float64) Sample

NewExpDecaySample constructs a new exponentially-decaying sample with the given reservoir size and alpha.

func NewUniformSample added in v3.1.0

func NewUniformSample(reservoirSize int) Sample

NewUniformSample constructs a new uniform sample with the given reservoir size.

type SampleSnapshot added in v3.1.0

type SampleSnapshot struct {
	// contains filtered or unexported fields
}

SampleSnapshot is a read-only copy of another Sample.

func (*SampleSnapshot) Clear added in v3.1.0

func (*SampleSnapshot) Clear()

Clear panics.

func (*SampleSnapshot) Count added in v3.1.0

func (s *SampleSnapshot) Count() int64

Count returns the count of inputs at the time the snapshot was taken.

func (*SampleSnapshot) Max added in v3.1.0

func (s *SampleSnapshot) Max() int64

Max returns the maximal value at the time the snapshot was taken.

func (*SampleSnapshot) Mean added in v3.1.0

func (s *SampleSnapshot) Mean() float64

Mean returns the mean value at the time the snapshot was taken.

func (*SampleSnapshot) Min added in v3.1.0

func (s *SampleSnapshot) Min() int64

Min returns the minimal value at the time the snapshot was taken.

func (*SampleSnapshot) Percentile added in v3.1.0

func (s *SampleSnapshot) Percentile(p float64) float64

Percentile returns an arbitrary percentile of values at the time the snapshot was taken.

func (*SampleSnapshot) Percentiles added in v3.1.0

func (s *SampleSnapshot) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of values at the time the snapshot was taken.

func (*SampleSnapshot) Size added in v3.1.0

func (s *SampleSnapshot) Size() int

Size returns the size of the sample at the time the snapshot was taken.

func (*SampleSnapshot) Snapshot added in v3.1.0

func (s *SampleSnapshot) Snapshot() Sample

Snapshot returns the snapshot.

func (*SampleSnapshot) StdDev added in v3.1.0

func (s *SampleSnapshot) StdDev() float64

StdDev returns the standard deviation of values at the time the snapshot was taken.

func (*SampleSnapshot) Sum added in v3.1.0

func (s *SampleSnapshot) Sum() int64

Sum returns the sum of values at the time the snapshot was taken.

func (*SampleSnapshot) Update added in v3.1.0

func (*SampleSnapshot) Update(int64)

Update panics.

func (*SampleSnapshot) Values added in v3.1.0

func (s *SampleSnapshot) Values() []int64

Values returns a copy of the values in the sample.

func (*SampleSnapshot) Variance added in v3.1.0

func (s *SampleSnapshot) Variance() float64

Variance returns the variance of values at the time the snapshot was taken.

type StandardCounter

type StandardCounter struct {
	*MetricMeta
	// contains filtered or unexported fields
}

StandardCounter is the standard implementation of a Counter and uses the sync/atomic package to manage a single int64 value.

func (*StandardCounter) Clear

func (c *StandardCounter) Clear()

Clear sets the counter to zero.

func (*StandardCounter) Count

func (c *StandardCounter) Count() int64

Count returns the current count.

func (*StandardCounter) Dec

func (c *StandardCounter) Dec(i int64)

Dec decrements the counter by the given amount.

func (*StandardCounter) Inc

func (c *StandardCounter) Inc(i int64)

Inc increments the counter by the given amount.

func (*StandardCounter) Snapshot

func (c *StandardCounter) Snapshot() Metric

type StandardEWMA added in v3.1.0

type StandardEWMA struct {
	// contains filtered or unexported fields
}

StandardEWMA is the standard implementation of an EWMA and tracks the number of uncounted events and processes them on each tick. It uses the sync/atomic package to manage uncounted events.

func (*StandardEWMA) Rate added in v3.1.0

func (a *StandardEWMA) Rate() float64

Rate returns the moving average rate of events per second.

func (*StandardEWMA) Snapshot added in v3.1.0

func (a *StandardEWMA) Snapshot() EWMA

Snapshot returns a read-only copy of the EWMA.

func (*StandardEWMA) Tick added in v3.1.0

func (a *StandardEWMA) Tick()

Tick ticks the clock to update the moving average. It assumes it is called every five seconds.

func (*StandardEWMA) Update added in v3.1.0

func (a *StandardEWMA) Update(n int64)

Update adds n uncounted events.

type StandardGauge added in v3.1.0

type StandardGauge struct {
	*MetricMeta
	// contains filtered or unexported fields
}

StandardGauge is the standard implementation of a Gauge and uses the sync/atomic package to manage a single int64 value.

func (*StandardGauge) Snapshot added in v3.1.0

func (g *StandardGauge) Snapshot() Metric

Snapshot returns a read-only copy of the gauge.

func (*StandardGauge) Update added in v3.1.0

func (g *StandardGauge) Update(v int64)

Update updates the gauge's value.

func (*StandardGauge) Value added in v3.1.0

func (g *StandardGauge) Value() int64

Value returns the gauge's current value.

type StandardHistogram added in v3.1.0

type StandardHistogram struct {
	*MetricMeta
	// contains filtered or unexported fields
}

StandardHistogram is the standard implementation of a Histogram and uses a Sample to bound its memory use.

func (*StandardHistogram) Clear added in v3.1.0

func (h *StandardHistogram) Clear()

Clear clears the histogram and its sample.

func (*StandardHistogram) Count added in v3.1.0

func (h *StandardHistogram) Count() int64

Count returns the number of samples recorded since the histogram was last cleared.

func (*StandardHistogram) Max added in v3.1.0

func (h *StandardHistogram) Max() int64

Max returns the maximum value in the sample.

func (*StandardHistogram) Mean added in v3.1.0

func (h *StandardHistogram) Mean() float64

Mean returns the mean of the values in the sample.

func (*StandardHistogram) Min added in v3.1.0

func (h *StandardHistogram) Min() int64

Min returns the minimum value in the sample.

func (*StandardHistogram) Percentile added in v3.1.0

func (h *StandardHistogram) Percentile(p float64) float64

Percentile returns an arbitrary percentile of the values in the sample.

func (*StandardHistogram) Percentiles added in v3.1.0

func (h *StandardHistogram) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of the values in the sample.

func (*StandardHistogram) Sample added in v3.1.0

func (h *StandardHistogram) Sample() Sample

Sample returns the Sample underlying the histogram.

func (*StandardHistogram) Snapshot added in v3.1.0

func (h *StandardHistogram) Snapshot() Metric

Snapshot returns a read-only copy of the histogram.

func (*StandardHistogram) StdDev added in v3.1.0

func (h *StandardHistogram) StdDev() float64

StdDev returns the standard deviation of the values in the sample.

func (*StandardHistogram) Sum added in v3.1.0

func (h *StandardHistogram) Sum() int64

Sum returns the sum in the sample.

func (*StandardHistogram) Update added in v3.1.0

func (h *StandardHistogram) Update(v int64)

Update samples a new value.

func (*StandardHistogram) Variance added in v3.1.0

func (h *StandardHistogram) Variance() float64

Variance returns the variance of the values in the sample.

type StandardMeter added in v3.1.0

type StandardMeter struct {
	*MetricMeta
	// contains filtered or unexported fields
}

StandardMeter is the standard implementation of a Meter.

func (*StandardMeter) Count added in v3.1.0

func (m *StandardMeter) Count() int64

Count returns the number of events recorded.

func (*StandardMeter) Mark added in v3.1.0

func (m *StandardMeter) Mark(n int64)

Mark records the occurance of n events.

func (*StandardMeter) Rate1 added in v3.1.0

func (m *StandardMeter) Rate1() float64

Rate1 returns the one-minute moving average rate of events per second.

func (*StandardMeter) Rate15 added in v3.1.0

func (m *StandardMeter) Rate15() float64

Rate15 returns the fifteen-minute moving average rate of events per second.

func (*StandardMeter) Rate5 added in v3.1.0

func (m *StandardMeter) Rate5() float64

Rate5 returns the five-minute moving average rate of events per second.

func (*StandardMeter) RateMean added in v3.1.0

func (m *StandardMeter) RateMean() float64

RateMean returns the meter's mean rate of events per second.

func (*StandardMeter) Snapshot added in v3.1.0

func (m *StandardMeter) Snapshot() Metric

Snapshot returns a read-only copy of the meter.

type StandardRegistry

type StandardRegistry struct {
	// contains filtered or unexported fields
}

The standard implementation of a Registry is a mutex-protected map of names to metrics.

func (*StandardRegistry) GetSnapshots added in v3.1.0

func (r *StandardRegistry) GetSnapshots() []Metric

Call the given function for each registered metric.

func (*StandardRegistry) Register

func (r *StandardRegistry) Register(metric Metric)

type StandardTimer added in v3.1.0

type StandardTimer struct {
	*MetricMeta
	// contains filtered or unexported fields
}

StandardTimer is the standard implementation of a Timer and uses a Histogram and Meter.

func (*StandardTimer) Count added in v3.1.0

func (t *StandardTimer) Count() int64

Count returns the number of events recorded.

func (*StandardTimer) Max added in v3.1.0

func (t *StandardTimer) Max() int64

Max returns the maximum value in the sample.

func (*StandardTimer) Mean added in v3.1.0

func (t *StandardTimer) Mean() float64

Mean returns the mean of the values in the sample.

func (*StandardTimer) Min added in v3.1.0

func (t *StandardTimer) Min() int64

Min returns the minimum value in the sample.

func (*StandardTimer) Percentile added in v3.1.0

func (t *StandardTimer) Percentile(p float64) float64

Percentile returns an arbitrary percentile of the values in the sample.

func (*StandardTimer) Percentiles added in v3.1.0

func (t *StandardTimer) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of the values in the sample.

func (*StandardTimer) Rate1 added in v3.1.0

func (t *StandardTimer) Rate1() float64

Rate1 returns the one-minute moving average rate of events per second.

func (*StandardTimer) Rate15 added in v3.1.0

func (t *StandardTimer) Rate15() float64

Rate15 returns the fifteen-minute moving average rate of events per second.

func (*StandardTimer) Rate5 added in v3.1.0

func (t *StandardTimer) Rate5() float64

Rate5 returns the five-minute moving average rate of events per second.

func (*StandardTimer) RateMean added in v3.1.0

func (t *StandardTimer) RateMean() float64

RateMean returns the meter's mean rate of events per second.

func (*StandardTimer) Snapshot added in v3.1.0

func (t *StandardTimer) Snapshot() Metric

Snapshot returns a read-only copy of the timer.

func (*StandardTimer) StdDev added in v3.1.0

func (t *StandardTimer) StdDev() float64

StdDev returns the standard deviation of the values in the sample.

func (*StandardTimer) Sum added in v3.1.0

func (t *StandardTimer) Sum() int64

Sum returns the sum in the sample.

func (*StandardTimer) Time added in v3.1.0

func (t *StandardTimer) Time(f func())

Record the duration of the execution of the given function.

func (*StandardTimer) Update added in v3.1.0

func (t *StandardTimer) Update(d time.Duration)

Record the duration of an event.

func (*StandardTimer) UpdateSince added in v3.1.0

func (t *StandardTimer) UpdateSince(ts time.Time)

Record the duration of an event that started at a time and ends now.

func (*StandardTimer) Variance added in v3.1.0

func (t *StandardTimer) Variance() float64

Variance returns the variance of the values in the sample.

type Timer added in v3.1.0

type Timer interface {
	Metric

	Count() int64
	Max() int64
	Mean() float64
	Min() int64
	Percentile(float64) float64
	Percentiles([]float64) []float64
	Rate1() float64
	Rate5() float64
	Rate15() float64
	RateMean() float64
	StdDev() float64
	Sum() int64
	Time(func())
	Update(time.Duration)
	UpdateSince(time.Time)
	Variance() float64
}

Timers capture the duration and rate of events.

func NewCustomTimer added in v3.1.0

func NewCustomTimer(meta *MetricMeta, h Histogram, m Meter) Timer

NewCustomTimer constructs a new StandardTimer from a Histogram and a Meter.

func NewTimer added in v3.1.0

func NewTimer(meta *MetricMeta) Timer

NewTimer constructs a new StandardTimer using an exponentially-decaying sample with the same reservoir size and alpha as UNIX load averages.

func RegTimer added in v3.1.0

func RegTimer(name string, tagStrings ...string) Timer

type TimerSnapshot added in v3.1.0

type TimerSnapshot struct {
	*MetricMeta
	// contains filtered or unexported fields
}

TimerSnapshot is a read-only copy of another Timer.

func (*TimerSnapshot) Count added in v3.1.0

func (t *TimerSnapshot) Count() int64

Count returns the number of events recorded at the time the snapshot was taken.

func (*TimerSnapshot) Max added in v3.1.0

func (t *TimerSnapshot) Max() int64

Max returns the maximum value at the time the snapshot was taken.

func (*TimerSnapshot) Mean added in v3.1.0

func (t *TimerSnapshot) Mean() float64

Mean returns the mean value at the time the snapshot was taken.

func (*TimerSnapshot) Min added in v3.1.0

func (t *TimerSnapshot) Min() int64

Min returns the minimum value at the time the snapshot was taken.

func (*TimerSnapshot) Percentile added in v3.1.0

func (t *TimerSnapshot) Percentile(p float64) float64

Percentile returns an arbitrary percentile of sampled values at the time the snapshot was taken.

func (*TimerSnapshot) Percentiles added in v3.1.0

func (t *TimerSnapshot) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of sampled values at the time the snapshot was taken.

func (*TimerSnapshot) Rate1 added in v3.1.0

func (t *TimerSnapshot) Rate1() float64

Rate1 returns the one-minute moving average rate of events per second at the time the snapshot was taken.

func (*TimerSnapshot) Rate15 added in v3.1.0

func (t *TimerSnapshot) Rate15() float64

Rate15 returns the fifteen-minute moving average rate of events per second at the time the snapshot was taken.

func (*TimerSnapshot) Rate5 added in v3.1.0

func (t *TimerSnapshot) Rate5() float64

Rate5 returns the five-minute moving average rate of events per second at the time the snapshot was taken.

func (*TimerSnapshot) RateMean added in v3.1.0

func (t *TimerSnapshot) RateMean() float64

RateMean returns the meter's mean rate of events per second at the time the snapshot was taken.

func (*TimerSnapshot) Snapshot added in v3.1.0

func (t *TimerSnapshot) Snapshot() Metric

Snapshot returns the snapshot.

func (*TimerSnapshot) StdDev added in v3.1.0

func (t *TimerSnapshot) StdDev() float64

StdDev returns the standard deviation of the values at the time the snapshot was taken.

func (*TimerSnapshot) Sum added in v3.1.0

func (t *TimerSnapshot) Sum() int64

Sum returns the sum at the time the snapshot was taken.

func (*TimerSnapshot) Time added in v3.1.0

func (*TimerSnapshot) Time(func())

Time panics.

func (*TimerSnapshot) Update added in v3.1.0

func (*TimerSnapshot) Update(time.Duration)

Update panics.

func (*TimerSnapshot) UpdateSince added in v3.1.0

func (*TimerSnapshot) UpdateSince(time.Time)

UpdateSince panics.

func (*TimerSnapshot) Variance added in v3.1.0

func (t *TimerSnapshot) Variance() float64

Variance returns the variance of the values at the time the snapshot was taken.

type UniformSample added in v3.1.0

type UniformSample struct {
	// contains filtered or unexported fields
}

A uniform sample using Vitter's Algorithm R.

<http://www.cs.umd.edu/~samir/498/vitter.pdf>

func (*UniformSample) Clear added in v3.1.0

func (s *UniformSample) Clear()

Clear clears all samples.

func (*UniformSample) Count added in v3.1.0

func (s *UniformSample) Count() int64

Count returns the number of samples recorded, which may exceed the reservoir size.

func (*UniformSample) Max added in v3.1.0

func (s *UniformSample) Max() int64

Max returns the maximum value in the sample, which may not be the maximum value ever to be part of the sample.

func (*UniformSample) Mean added in v3.1.0

func (s *UniformSample) Mean() float64

Mean returns the mean of the values in the sample.

func (*UniformSample) Min added in v3.1.0

func (s *UniformSample) Min() int64

Min returns the minimum value in the sample, which may not be the minimum value ever to be part of the sample.

func (*UniformSample) Percentile added in v3.1.0

func (s *UniformSample) Percentile(p float64) float64

Percentile returns an arbitrary percentile of values in the sample.

func (*UniformSample) Percentiles added in v3.1.0

func (s *UniformSample) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of values in the sample.

func (*UniformSample) Size added in v3.1.0

func (s *UniformSample) Size() int

Size returns the size of the sample, which is at most the reservoir size.

func (*UniformSample) Snapshot added in v3.1.0

func (s *UniformSample) Snapshot() Sample

Snapshot returns a read-only copy of the sample.

func (*UniformSample) StdDev added in v3.1.0

func (s *UniformSample) StdDev() float64

StdDev returns the standard deviation of the values in the sample.

func (*UniformSample) Sum added in v3.1.0

func (s *UniformSample) Sum() int64

Sum returns the sum of the values in the sample.

func (*UniformSample) Update added in v3.1.0

func (s *UniformSample) Update(v int64)

Update samples a new value.

func (*UniformSample) Values added in v3.1.0

func (s *UniformSample) Values() []int64

Values returns a copy of the values in the sample.

func (*UniformSample) Variance added in v3.1.0

func (s *UniformSample) Variance() float64

Variance returns the variance of the values in the sample.

Jump to

Keyboard shortcuts

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