Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.74 KB

README.md

File metadata and controls

52 lines (38 loc) · 1.74 KB

Go-metrics Exporters

GitHub Actions GitHub Release Go Report Card Go Version License Apache-2.0

Export go-metrics to multiple upstreams with Emitter, and gracefully close it.

Features

  • 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

Usage Examples

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.

Alternatives

See go-metrics#publishing-metrics for alternatives.