expvar

package
v0.0.0-...-4a35c31 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2015 License: MIT Imports: 7 Imported by: 0

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.

Index

Constants

This section is empty.

Variables

This section is empty.

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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