Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Go port of Coda Hale's Metrics library

branch: master
Octocat-spinner-32 cmd initial implementation of GaugeFloat64 March 22, 2014
Octocat-spinner-32 influxdb initial implementation of GaugeFloat64 March 22, 2014
Octocat-spinner-32 librato initial implementation of GaugeFloat64 March 22, 2014
Octocat-spinner-32 stathat initial implementation of GaugeFloat64 March 22, 2014
Octocat-spinner-32 .gitignore never-read debugging tool. August 09, 2013
Octocat-spinner-32 LICENSE Updated docs, deleted Makefiles. February 23, 2012
Octocat-spinner-32 README.md Update README.md March 21, 2014
Octocat-spinner-32 counter.go Allow lazy instantiation of metric in GetOrRegister. March 28, 2014
Octocat-spinner-32 counter_test.go Fully introduce snapshots for all metric types. January 07, 2014
Octocat-spinner-32 debug.go Research, benchmarks, and tests. October 30, 2013
Octocat-spinner-32 debug_test.go Skip tests that require GOMAXPROCS > 1. October 31, 2013
Octocat-spinner-32 ewma.go ewma: ensure 64-bit alignment of uncounted January 25, 2014
Octocat-spinner-32 ewma_test.go Benchmarks for everyone! October 17, 2013
Octocat-spinner-32 gauge.go Allow lazy instantiation of metric in GetOrRegister. March 28, 2014
Octocat-spinner-32 gauge_float64.go Do not export methods from sync.Mutex on gauges. March 22, 2014
Octocat-spinner-32 gauge_float64_test.go Tidying whitespace. March 22, 2014
Octocat-spinner-32 gauge_test.go Fully introduce snapshots for all metric types. January 07, 2014
Octocat-spinner-32 graphite.go initial implementation of GaugeFloat64 March 22, 2014
Octocat-spinner-32 graphite_test.go Merge branch 'graphite-config' January 14, 2014
Octocat-spinner-32 healthcheck.go Mostly documentation and naming changes. January 07, 2014
Octocat-spinner-32 histogram.go Allow lazy instantiation of metric in GetOrRegister. March 28, 2014
Octocat-spinner-32 histogram_test.go Fix tests broken by sample changes. January 14, 2014
Octocat-spinner-32 json.go initial implementation of GaugeFloat64 March 22, 2014
Octocat-spinner-32 log.go initial implementation of GaugeFloat64 March 22, 2014
Octocat-spinner-32 memory.md Installation and usage. November 21, 2011
Octocat-spinner-32 meter.go Allow lazy instantiation of metric in GetOrRegister. March 28, 2014
Octocat-spinner-32 meter_test.go Fully introduce snapshots for all metric types. January 07, 2014
Octocat-spinner-32 metrics.go ETOOCLEVER so s/ObserverEffect/UseNilMetrics/. September 13, 2013
Octocat-spinner-32 metrics_test.go initial implementation of GaugeFloat64 March 22, 2014
Octocat-spinner-32 registry.go Tidy up name and whitespace. March 28, 2014
Octocat-spinner-32 registry_test.go Allow lazy instantiation of metric in GetOrRegister. March 28, 2014
Octocat-spinner-32 runtime.go Rework NumGC and PauseNs runtime metrics. March 22, 2014
Octocat-spinner-32 runtime_test.go Rework NumGC and PauseNs runtime metrics. March 22, 2014
Octocat-spinner-32 sample.go Calculate all histogram statistics from samples. January 09, 2014
Octocat-spinner-32 sample_test.go Fully introduce snapshots for all metric types. January 07, 2014
Octocat-spinner-32 syslog.go initial implementation of GaugeFloat64 March 22, 2014
Octocat-spinner-32 timer.go Allow lazy instantiation of metric in GetOrRegister. March 28, 2014
Octocat-spinner-32 timer_test.go Fix tests broken by sample changes. January 14, 2014
Octocat-spinner-32 writer.go initial implementation of GaugeFloat64 March 22, 2014
README.md

go-metrics

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

Documentation: http://godoc.org/github.com/rcrowley/go-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.Register("quux", m)
m.Mark(47)

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

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

go metrics.Log(metrics.DefaultRegistry, 60e9, 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")
go metrics.Syslog(metrics.DefaultRegistry, 60e9, w)

Periodically emit every metric to Graphite:

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

Periodically emit every metric to StatHat:

import "github.com/rcrowley/go-metrics/stathat"

go stathat.Stathat(metrics.DefaultRegistry, 10e9, "example@example.com")

Periodically emit every metric into Influxdb:

import "github.com/rcrowley/go-metrics/influxdb"

go influxdb.Influxdb(metrics.DefaultRegistry, 10e9, &influxdb.Config{
    Host:     "127.0.0.1:8086",
    Database: "metrics",
    Username: "test",
    Password: "test",
})

Installation

go get github.com/rcrowley/go-metrics

StatHat support additionally requires their Go client:

go get github.com/stathat/go
Something went wrong with that request. Please try again.