This golang package is used for monitoring emitter.io cluster. This provides a tight binary compression and a single histogram/counter abstraction in order to deal with various kinds of system monitoring. This package is compatible with GopherJS (snapshot-only) and hence can also be compiled to javascript. Documentation is available on go doc.
go get -u github.com/emitter-io/stats
The package itself provides a general-purpose monitoring capabilities, with tight encoding using our binary codec. While it's primarily have been built for emitter, it can be used anywhere.
Typical usage consists of creating a metric container, measuring various metrics and sending snapshots over the wire.
rand.Seed(time.Now().UnixNano())
// Create a container
m := stats.New()
// Measure few metrics
m.Measure("my.metric.1", rand.Int31n(1000))
m.Measure("my.metric.2", rand.Int31n(1000))
// Create a snapshot which can be transferred over the wire
bytes := m.Snapshot()
// Restore a snapshot from binary
v, err := stats.Restore(bytes)
// Get the values back
percentiles := v[0].Quantile(50, 90, 95, 99)
average := v[0].Mean()
count := v[0].Count()