Documentation ¶
Overview ¶
Package expvar implements an expvar backend for package metrics.
The current implementation ignores fields. In the future, it would be good to have an implementation that accepted a set of predeclared field names at construction time, and used field values to produce delimiter-separated bucket (key) names. That is,
c := NewFieldedCounter(..., "path", "status") c.Add(1) // "myprefix_unknown_unknown" += 1 c2 := c.With("path", "foo").With("status": "200") c2.Add(1) // "myprefix_foo_200" += 1
It would also be possible to have an implementation that generated more sophisticated expvar.Values. For example, a Counter could be implemented as a map, representing a tree of key/value pairs whose leaves were the actual expvar.Ints.
Histogram observation count is exported as a counter called name + "_count"
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCounter ¶
NewCounter returns a new Counter backed by an expvar with the given name. Fields are ignored.
func NewGauge ¶
NewGauge returns a new Gauge backed by an expvar with the given name. It should be updated manually; for a callback-based approach, see PublishCallbackGauge. Fields are ignored.
func NewHistogram ¶
func NewHistogram(name string, minValue, maxValue int64, sigfigs int, quantiles ...int) metrics.Histogram
NewHistogram is taken from http://github.com/codahale/metrics. It returns a windowed HDR histogram which drops data older than five minutes.
The histogram exposes metrics for each passed quantile as gauges. Quantiles should be integers in the range 1..99. The gauge names are assigned by using the passed name as a prefix and appending "_pNN" e.g. "_p50".
func PublishCallbackGauge ¶
PublishCallbackGauge publishes a Gauge as an expvar with the given name, whose value is determined at collect time by the passed callback function. The callback determines the value, and fields are ignored, so PublishCallbackGauge returns nothing.
Types ¶
This section is empty.