Documentation ¶
Overview ¶
Package metric defines the standard interface for metrics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counter ¶
type Counter interface { // Name returns the name of the metric. Name() string // Inc increments the counter by one. Inc(...string) // Add increments the counter by increment. It must panic if increment is // negative. Add(increment float64, labels ...string) }
Counter is a metric that can only ever increase. Labels are provided as alternating keys and values.
type Gauge ¶
type Gauge interface { // Name returns the name of the metric. Name() string // Inc increments the gauge by one. Inc(...string) // Dec decrements the gauge by one. Dec(...string) // Add increments the gauge by delta, which may be negative. Add(delta float64, labels ...string) // Set sets the gauge to value. Set(value float64, labels ...string) }
Gauge is a metric that represents a value that can go up and down. Labels are provided as alternating keys and values.
type Histogram ¶
type Histogram interface { // Name returns the name of the metric. Name() string // Observe records observation of the specified value. Observe(value float64, labels ...string) }
Histogram records observed values. Labels are provided as alternating keys and values.
type MockCounter ¶
type MockCounter struct { NameFunc func() string IncFunc func(...string) AddFunc func(float64, ...string) }
MockCounter is a test mock for the Counter interface.
func (*MockCounter) Add ¶
func (m *MockCounter) Add(inc float64, labels ...string)
func (*MockCounter) Inc ¶
func (m *MockCounter) Inc(labels ...string)
func (*MockCounter) Name ¶
func (m *MockCounter) Name() string
type MockGauge ¶
type MockGauge struct { NameFunc func() string IncFunc func(...string) DecFunc func(...string) AddFunc func(float64, ...string) SetFunc func(float64, ...string) }
MockGauge is a test mock for the Gauge interface.
type MockHistogram ¶
MockHistogram is a test mock for the Histogram interface.
func (*MockHistogram) Name ¶
func (m *MockHistogram) Name() string
func (*MockHistogram) Observe ¶
func (m *MockHistogram) Observe(v float64, labels ...string)
type MockProvider ¶
type MockProvider struct { NewCounterFunc func(string, float64, ...string) (Counter, error) NewGaugeFunc func(string, float64, ...string) (Gauge, error) NewHistogramFunc func(string, float64, ...string) (Histogram, error) }
MockProvider is a test mock for the Provider interface.
func (*MockProvider) NewCounter ¶
func (*MockProvider) NewHistogram ¶
type Provider ¶
type Provider interface { // NewCounter creates a new Counter metric. Labels provided here are // common labels applied to all values. The sample is a value between // 0 and 1, 1 meaning all values are recorded. NewCounter(name string, sample float64, labels ...string) (Counter, error) // NewGauge creates a new Gauge metric. Labels provided here are // common labels applied to all values. The sample is a value between // 0 and 1, 1 meaning all values are recorded. NewGauge(name string, sample float64, labels ...string) (Gauge, error) // NewHistogram creates a new Histogram metric. Labels provided here are // common labels applied to all values. The sample is a value between // 0 and 1, 1 meaning all values are recorded. NewHistogram(name string, sample float64, labels ...string) (Histogram, error) }
Provider defines the methods that provide metrics.