Categorygithub.com/inconshreveable/go-metrics
modulepackage
0.0.0-20130330042608-60ba4ca70cf6
Repository: https://github.com/inconshreveable/go-metrics.git
Documentation: pkg.go.dev

# README

go-metrics

Go port of Coda Hale's Metrics library: https://github.com/codahale/metrics.

Usage

Create and update metrics:

c := metrics.NewCounter()
metrics.Register("foo", c)
c.Inc(47)

g := metrics.NewGauge()
metrics.Register("bar", g)
g.Update(47)

s := metrics.NewExpDecaySample(1028, 0.015) // or metrics.NewUniformSample(1028)
h := metrics.NewHistogram(s)
metrics.Register("baz", h)
h.Update(47)

m := metrics.NewMeter()
metrics.RegisterMeter("quux", m)
m.Mark(47)

t := metrics.NewTimer()
metrics.RegisterTimer("bang", t)
t.Time(func() {})
t.Update(47)

Periodically log every metric in human-readable form to standard error:

metrics.Log(metrics.DefaultRegistry, 60, log.New(os.Stderr, "metrics: ", log.Lmicroseconds))

Periodically log every metric in slightly-more-parseable form to syslog:

w, _ := syslog.Dial("unixgram", "/dev/log", syslog.LOG_INFO, "metrics")
metrics.Syslog(metrics.DefaultRegistry, 60, w)

Periodically emit every metric to Graphite:

addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003")
metrics.Graphite(metrics.DefaultRegistry, 10, "metrics", addr)

Installation

go get github.com/rcrowley/go-metrics

# Packages

No description provided by the author

# Functions

Capture new values for the Go runtime statistics exported in runtime.MemStats.
Capture new values for the Go runtime statistics exported in runtime.MemStats.
Call the given function for each registered metric.
Get the metric by the given name or nil if none is registered.
No description provided by the author
Output each metric in the given registry periodically using the given logger.
Create a new counter.
Create a new timer with the given Histogram and Meter.
Create a new EWMA with the given alpha.
Create a new EWMA with alpha set for a one-minute moving average.
Create a new EWMA with alpha set for a fifteen-minute moving average.
Create a new EWMA with alpha set for a five-minute moving average.
Create a new exponentially-decaying sample with the given reservoir size and alpha.
Create a new gauge.
Create a new healthcheck, which will use the given function to update its status.
Create a new histogram with the given Sample.
Create a new meter.
Create a new registry.
Create a new timer with a standard histogram and meter.
Create a new uniform sample with the given reservoir size.
Register the given metric under the given name.
Register metrics for the Go runtime statistics exported in runtime.MemStats.
Run all registered healthchecks.
Output each metric in the given registry to syslog periodically using the given syslogger.
Unregister the metric with the given name.

# Variables

No description provided by the author

# Structs

An exponentially-decaying sample using a forward-decaying priority reservoir.
The standard implementation of a Counter uses the sync/atomic package to manage a single int64 value.
The standard implementation of an EWMA tracks the number of uncounted events and processes them on each tick.
The standard implementation of a Gauge uses the sync/atomic package to manage a single int64 value.
The standard implementation of a Healthcheck stores the status and a function to call to update the status.
The standard implementation of a Histogram uses a Sample and a goroutine to synchronize its calculations.
The standard implementation of a Meter uses a goroutine to synchronize its calculations and another goroutine (via time.Ticker) to produce clock ticks.
The standard implementation of a Registry is a mutex-protected map of names to metrics.
The standard implementation of a Timer uses a Histogram and Meter directly.
A uniform sample using Vitter's Algorithm R.

# Interfaces

Counters hold an int64 value that can be incremented and decremented.
EWMAs continuously calculate an exponentially-weighted moving average based on an outside source of clock ticks.
Gauges hold an int64 value that can be set arbitrarily.
Healthchecks hold an os.Error value describing an arbitrary up/down status.
Histograms calculate distribution statistics from an int64 value.
Meters count events to produce exponentially-weighted moving average rates at one-, five-, and fifteen-minutes and a mean rate.
A Registry holds references to a set of metrics by name and can iterate over them, calling callback functions provided by the user.
Samples maintain a statistically-significant selection of values from a stream.
Timers capture the duration and rate of events.