graphite.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package provider
  2. import (
  3. "github.com/go-kit/kit/metrics"
  4. "github.com/go-kit/kit/metrics/graphite"
  5. )
  6. type graphiteProvider struct {
  7. g *graphite.Graphite
  8. stop func()
  9. }
  10. // NewGraphiteProvider wraps the given Graphite object and stop func and returns
  11. // a Provider that produces Graphite metrics. A typical stop function would be
  12. // ticker.Stop from the ticker passed to the SendLoop helper method.
  13. func NewGraphiteProvider(g *graphite.Graphite, stop func()) Provider {
  14. return &graphiteProvider{
  15. g: g,
  16. stop: stop,
  17. }
  18. }
  19. // NewCounter implements Provider.
  20. func (p *graphiteProvider) NewCounter(name string) metrics.Counter {
  21. return p.g.NewCounter(name)
  22. }
  23. // NewGauge implements Provider.
  24. func (p *graphiteProvider) NewGauge(name string) metrics.Gauge {
  25. return p.g.NewGauge(name)
  26. }
  27. // NewHistogram implements Provider.
  28. func (p *graphiteProvider) NewHistogram(name string, buckets int) metrics.Histogram {
  29. return p.g.NewHistogram(name, buckets)
  30. }
  31. // Stop implements Provider, invoking the stop function passed at construction.
  32. func (p *graphiteProvider) Stop() {
  33. p.stop()
  34. }