Export go-metrics to multiple upstreams with Emitter, and gracefully close it.
- Gracefully report last metrics when shutting down
- Report to multiple upstreams simultaneously
- Builtin influx v1 and v2 support
- Implement
Emitter
to support in-house upstreams
Report to stdout:
reg := metrics.NewRegistry()
stdout := emitters.NewStdoutEmitter()
rep, err := exporters.NewReporter(reg, 1*time.Second).WithEmitter(stdout).Start()
// Should close it when shutting down application
rep.Close()
Report to stdout and influx v2:
inf, _ := influx.NewV2Emitter(influxUrl, "bucket")
rep, err := exporters.NewReporter(reg, 1*time.Second).
WithEmitter(stdout).
WithEmitter(inf).
Start()
// Should close it when shutting down application
rep.Close()
See test for more examples.
See go-metrics#publishing-metrics for alternatives.