Giter Club home page Giter Club logo

go-metrics's Introduction

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 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",
})

Periodically upload every metric to Librato:

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

go librato.Librato(metrics.DefaultRegistry,
    10e9,                  // interval
    "[email protected]", // 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:

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

go stathat.Stathat(metrics.DefaultRegistry, 10e9, "[email protected]")

Installation

go get github.com/rcrowley/go-metrics

StatHat support additionally requires their Go client:

go get github.com/stathat/go

go-metrics's People

Contributors

rcrowley avatar mihasya avatar pietern avatar aleksi avatar bketelsen avatar attilaolah avatar jmhodges avatar kisielk avatar stuartcarnie avatar cyberdelia avatar aranair avatar mattkanwisher avatar crosbymichael avatar schmichael avatar pkwarren avatar tsenart avatar yvasiyarov avatar vincentbernat avatar wadey avatar defp avatar sonots avatar wolfeidau avatar mark-stripe avatar markchadwick avatar ianrose14 avatar donovanhide avatar daniel-garcia avatar abh avatar arikfr avatar inconshreveable avatar

Watchers

yeer avatar Son avatar Mon Geslani avatar anton effendi avatar Neeraj Kumar avatar Aulia Amalia avatar wilson avatar Inigo Sarmiento avatar Dang Nguyen Anh Khoa avatar Tien Nguyen avatar James Cloos avatar Ali avatar allenlsy avatar  avatar Muddsar avatar  avatar S Shahid avatar Michael Valladolid avatar Hu Chen avatar  avatar Ahsan Nabi Dar avatar Yagi Anggar Prahara avatar Edward Fernando avatar RajeshKanna avatar Sheldon Cheng avatar ubaidullah avatar Nedyalko Terziev avatar Tam Tran avatar  avatar Hansel Baro avatar Sohaib avatar Aah Ahmad Kusumah avatar SamEng avatar Pranjal Katlana avatar The web walker avatar Erwin avatar vibhav kumar avatar Tom Hoang avatar  avatar Tam Nguyen avatar Jeyee avatar  avatar rouly soufina siahaan avatar Cuong Dang avatar Farandy Rachman avatar kailin avatar Daniel Poon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.