package expvar

import "github.com/go-kit/kit/metrics/expvar"

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.

Index

Functions

func NewCounter

func NewCounter(name string) metrics.Counter

NewCounter returns a new Counter backed by an expvar with the given name. Fields are ignored.

func NewGauge

func NewGauge(name string) metrics.Gauge

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

func PublishCallbackGauge(name string, callback func() float64)

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.

Source Files

expvar.go

Version
v0.2.0
Published
Jul 27, 2016
Platform
windows/amd64
Imports
8 packages
Last checked
12 seconds ago

Tools for package owners.