|
|
пре 13 година | |
|---|---|---|
| cmd | пре 14 година | |
| .gitignore | пре 14 година | |
| LICENSE | пре 14 година | |
| README.md | пре 13 година | |
| counter.go | пре 14 година | |
| counter_test.go | пре 14 година | |
| ewma.go | пре 13 година | |
| ewma_test.go | пре 13 година | |
| gauge.go | пре 14 година | |
| gauge_test.go | пре 14 година | |
| graphite.go | пре 13 година | |
| healthcheck.go | пре 14 година | |
| histogram.go | пре 13 година | |
| histogram_test.go | пре 13 година | |
| log.go | пре 14 година | |
| memory.md | пре 14 година | |
| meter.go | пре 14 година | |
| meter_test.go | пре 14 година | |
| metrics.go | пре 14 година | |
| registry.go | пре 13 година | |
| runtime.go | пре 14 година | |
| sample.go | пре 13 година | |
| sample_test.go | пре 13 година | |
| syslog.go | пре 14 година | |
| timer.go | пре 14 година | |
| timer_test.go | пре 14 година |
Go port of Coda Hale's Metrics library: https://github.com/codahale/metrics.
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:
metrics.Graphite(metrics.DefaultRegistry, 60, "127.0.0.1:2003")
go get github.com/rcrowley/go-metrics