• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

cmd/H26-Sep-2014-199159

influxdb/H26-Sep-2014-115107

librato/H26-Sep-2014-348302

stathat/H26-Sep-2014-7065

.gitignoreH A D26-Sep-2014135 109

LICENSEH A D26-Sep-20141.5 KiB3024

README.mdH A D26-Sep-20142.2 KiB10576

counter.goH A D26-Sep-20142.5 KiB11365

counter_test.goH A D26-Sep-20141.4 KiB7867

debug.goH A D26-Sep-20142.6 KiB7749

debug_test.goH A D26-Sep-2014849 4944

ewma.goH A D26-Sep-20142.8 KiB11972

ewma_test.goH A D26-Sep-20146.9 KiB226219

gauge.goH A D26-Sep-20141.9 KiB8549

gauge_float64.goH A D26-Sep-20142.3 KiB9256

gauge_float64_test.goH A D26-Sep-2014838 3933

gauge_test.goH A D26-Sep-2014688 3832

graphite.goH A D26-Sep-20144 KiB10592

graphite_test.goH A D26-Sep-2014490 2319

healthcheck.goH A D26-Sep-20141.5 KiB6234

histogram.goH A D26-Sep-20145.7 KiB19394

histogram_test.goH A D26-Sep-20142.3 KiB9688

json.goH A D26-Sep-20142.2 KiB8473

json_test.goH A D26-Sep-2014536 2925

log.goH A D26-Sep-20142.5 KiB7166

memory.mdH A D26-Sep-20145.2 KiB286236

meter.goH A D26-Sep-20145.3 KiB234160

meter_test.goH A D26-Sep-20141.1 KiB6153

metrics.goH A D26-Sep-2014461 142

metrics_test.goH A D26-Sep-20141.8 KiB10860

opentsdb.goH A D26-Sep-20145.5 KiB120105

opentsdb_test.goH A D26-Sep-2014439 2318

registry.goH A D26-Sep-20144.6 KiB169104

registry_test.goH A D26-Sep-20142.1 KiB119105

runtime.goH A D26-Sep-20148.1 KiB201174

runtime_cgo.goH A D26-Sep-2014107 105

runtime_no_cgo.goH A D26-Sep-201471 84

runtime_test.goH A D26-Sep-20141.8 KiB7973

sample.goH A D26-Sep-201413.9 KiB569389

sample_test.goH A D26-Sep-20148.2 KiB353319

syslog.goH A D26-Sep-20141.9 KiB7972

timer.goH A D26-Sep-20147.8 KiB300173

timer_test.goH A D26-Sep-20141.8 KiB8275

writer.goH A D26-Sep-20143.5 KiB10186

writer_test.goH A D26-Sep-2014341 2319

README.md

1go-metrics
2==========
3
4Go port of Coda Hale's Metrics library: <https://github.com/codahale/metrics>.
5
6Documentation: <http://godoc.org/github.com/rcrowley/go-metrics>.
7
8Usage
9-----
10
11Create and update metrics:
12
13```go
14c := metrics.NewCounter()
15metrics.Register("foo", c)
16c.Inc(47)
17
18g := metrics.NewGauge()
19metrics.Register("bar", g)
20g.Update(47)
21
22s := metrics.NewExpDecaySample(1028, 0.015) // or metrics.NewUniformSample(1028)
23h := metrics.NewHistogram(s)
24metrics.Register("baz", h)
25h.Update(47)
26
27m := metrics.NewMeter()
28metrics.Register("quux", m)
29m.Mark(47)
30
31t := metrics.NewTimer()
32metrics.Register("bang", t)
33t.Time(func() {})
34t.Update(47)
35```
36
37Periodically log every metric in human-readable form to standard error:
38
39```go
40go metrics.Log(metrics.DefaultRegistry, 60e9, log.New(os.Stderr, "metrics: ", log.Lmicroseconds))
41```
42
43Periodically log every metric in slightly-more-parseable form to syslog:
44
45```go
46w, _ := syslog.Dial("unixgram", "/dev/log", syslog.LOG_INFO, "metrics")
47go metrics.Syslog(metrics.DefaultRegistry, 60e9, w)
48```
49
50Periodically emit every metric to Graphite:
51
52```go
53addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003")
54go metrics.Graphite(metrics.DefaultRegistry, 10e9, "metrics", addr)
55```
56
57Periodically emit every metric into InfluxDB:
58
59```go
60import "github.com/rcrowley/go-metrics/influxdb"
61
62go influxdb.Influxdb(metrics.DefaultRegistry, 10e9, &influxdb.Config{
63    Host:     "127.0.0.1:8086",
64    Database: "metrics",
65    Username: "test",
66    Password: "test",
67})
68```
69
70Periodically upload every metric to Librato:
71
72```go
73import "github.com/rcrowley/go-metrics/librato"
74
75go librato.Librato(metrics.DefaultRegistry,
76    10e9,                  // interval
77    "example@example.com", // account owner email address
78    "token",               // Librato API token
79    "hostname",            // source
80    []float64{0.95},       // precentiles to send
81    time.Millisecond,      // time unit
82)
83```
84
85Periodically emit every metric to StatHat:
86
87```go
88import "github.com/rcrowley/go-metrics/stathat"
89
90go stathat.Stathat(metrics.DefaultRegistry, 10e9, "example@example.com")
91```
92
93Installation
94------------
95
96```sh
97go get github.com/rcrowley/go-metrics
98```
99
100StatHat support additionally requires their Go client:
101
102```sh
103go get github.com/stathat/go
104```
105