Skip to content

juvenn/metric-exporters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.