Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Go port of Coda Hale's Metrics library
Go
branch: master

This branch is 209 commits behind rcrowley:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
cmd
.gitignore
LICENSE
README.md
counter.go
counter_test.go
ewma.go
ewma_test.go
gauge.go
gauge_test.go
healthcheck.go
histogram.go
histogram_test.go
log.go
memory.md
meter.go
meter_test.go
metrics.go
registry.go
runtime.go
sample.go
sample_test.go
syslog.go
timer.go
timer_test.go

README.md

go-metrics

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

Usage

Create and update metrics:

r := metrics.NewRegistry()

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

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

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

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

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

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

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

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

w, err := syslog.Dial("unixgram", "/dev/log", syslog.LOG_INFO, "metrics")
if nil != err { log.Fatalln(err) }
metrics.Syslog(r, 60, w)

Installation

go install github.com/rcrowley/go-metrics
Something went wrong with that request. Please try again.