1 // Package provider provides a factory-like abstraction for metrics backends.
2 // This package is provided specifically for the needs of the NY Times framework
3 // Gizmo. Most normal Go kit users shouldn't need to use it.
5 // Normally, if your microservice needs to support different metrics backends,
6 // you can simply do different construction based on a flag. For example,
8 // var latency metrics.Histogram
9 // var requests metrics.Counter
10 // switch *metricsBackend {
12 // latency = prometheus.NewSummaryVec(...)
13 // requests = prometheus.NewCounterVec(...)
15 // s := statsd.New(...)
16 // t := time.NewTicker(5*time.Second)
17 // go s.SendLoop(t.C, "tcp", "statsd.local:8125")
18 // latency = s.NewHistogram(...)
19 // requests = s.NewCounter(...)
21 // log.Fatal("unsupported metrics backend %q", *metricsBackend)
27 "github.com/go-kit/kit/metrics"
30 // Provider abstracts over constructors and lifecycle management functions for
31 // each supported metrics backend. It should only be used by those who need to
32 // swap out implementations dynamically.
34 // This is primarily useful for intermediating frameworks, and is likely
35 // unnecessary for most Go kit services. See the package-level doc comment for
36 // more typical usage instructions.
37 type Provider interface {
38 NewCounter(name string) metrics.Counter
39 NewGauge(name string) metrics.Gauge
40 NewHistogram(name string, buckets int) metrics.Histogram