influx.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package provider
  2. import (
  3. "github.com/go-kit/kit/metrics"
  4. "github.com/go-kit/kit/metrics/influx"
  5. )
  6. type influxProvider struct {
  7. in *influx.Influx
  8. stop func()
  9. }
  10. // NewInfluxProvider takes the given Influx object and stop func, and returns
  11. // a Provider that produces Influx metrics.
  12. func NewInfluxProvider(in *influx.Influx, stop func()) Provider {
  13. return &influxProvider{
  14. in: in,
  15. stop: stop,
  16. }
  17. }
  18. // NewCounter implements Provider. Per-metric tags are not supported.
  19. func (p *influxProvider) NewCounter(name string) metrics.Counter {
  20. return p.in.NewCounter(name)
  21. }
  22. // NewGauge implements Provider. Per-metric tags are not supported.
  23. func (p *influxProvider) NewGauge(name string) metrics.Gauge {
  24. return p.in.NewGauge(name)
  25. }
  26. // NewHistogram implements Provider. Per-metric tags are not supported.
  27. func (p *influxProvider) NewHistogram(name string, buckets int) metrics.Histogram {
  28. return p.in.NewHistogram(name)
  29. }
  30. // Stop implements Provider, invoking the stop function passed at construction.
  31. func (p *influxProvider) Stop() {
  32. p.stop()
  33. }