pressly/go-metrics

Name: go-metrics

Owner: Pressly Inc.

Description: Go port of Coda Hale's Metrics library

Created: 2015-04-17 15:43:18.0

Updated: 2015-04-17 17:42:03.0

Pushed: 2015-04-17 17:42:03.0

Homepage:

Size: 1259

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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:

 metrics.NewCounter()
ics.Register("foo", c)
c(47)

 metrics.NewGauge()
ics.Register("bar", g)
date(47)

 metrics.NewExpDecaySample(1028, 0.015) // or metrics.NewUniformSample(1028)
 metrics.NewHistogram(s)
ics.Register("baz", h)
date(47)

 metrics.NewMeter()
ics.Register("quux", m)
rk(47)

 metrics.NewTimer()
ics.Register("bang", t)
me(func() {})
date(47)

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

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

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

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

Periodically emit every metric to Graphite:

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

Periodically emit every metric into InfluxDB:

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

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

Periodically upload every metric to Librato:

rt "github.com/rcrowley/go-metrics/librato"

ibrato.Librato(metrics.DefaultRegistry,
10e9,                  // interval
"example@example.com", // account owner email address
"token",               // Librato API token
"hostname",            // source
[]float64{0.95},       // precentiles to send
time.Millisecond,      // time unit

Periodically emit every metric to StatHat:

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

tathat.Stathat(metrics.DefaultRegistry, 10e9, "example@example.com")
Installation
et github.com/rcrowley/go-metrics

StatHat support additionally requires their Go client:

et github.com/stathat/go

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.