Documentation ¶
Overview ¶
Package metrics provides minimalist instrumentation for your applications in the form of counters and gauges.
Counters ¶
A counter is a monotonically-increasing, unsigned, 64-bit integer used to represent the number of times an event has occurred. By tracking the deltas between measurements of a counter over intervals of time, an aggregation layer can derive rates, acceleration, etc.
Gauges ¶
A gauge returns instantaneous measurements of something using signed, 64-bit integers. This value does not need to be monotonic.
Histograms ¶
A histogram tracks the distribution of a stream of values (e.g. the number of milliseconds it takes to handle requests), adding gauges for the values at meaningful quantiles: 50th, 75th, 90th, 95th, 99th, 99.9th.
Reporting ¶
Measurements from counters and gauges are available as expvars. Your service should return its expvars from an HTTP endpoint (i.e., /debug/vars) as a JSON object.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Counter ¶
type Counter string
A Counter is a monotonically increasing unsigned integer.
Use a counter to derive rates (e.g., record total number of requests, derive requests per second).
func (Counter) SetBatchFunc ¶
SetBatchFunc sets the counter's value to the lazily-called return value of the given function, with an additional initializer function for a related batch of counters, all of which are keyed by an arbitrary value.
type Gauge ¶
type Gauge string
A Gauge is an instantaneous measurement of a value.
Use a gauge to track metrics which increase and decrease (e.g., amount of free memory).
func (Gauge) SetBatchFunc ¶
SetBatchFunc sets the gauge's value to the lazily-called return value of the given function, with an additional initializer function for a related batch of gauges, all of which are keyed by an arbitrary value.
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
A Histogram measures the distribution of a stream of values.
func NewHistogram ¶
NewHistogram returns a windowed HDR histogram which drops data older than five minutes. The returned histogram is safe to use from multiple goroutines.
Use a histogram to track the distribution of a stream of values (e.g., the latency associated with HTTP requests).
func (*Histogram) RecordValue ¶
RecordValue records the given value, or returns an error if the value is out of range. Returned error values are of type Error.