4 stdprometheus "github.com/prometheus/client_golang/prometheus"
6 "github.com/go-kit/kit/metrics"
7 "github.com/go-kit/kit/metrics/prometheus"
10 type prometheusProvider struct {
15 // NewPrometheusProvider returns a Provider that produces Prometheus metrics.
16 // Namespace and subsystem are applied to all produced metrics.
17 func NewPrometheusProvider(namespace, subsystem string) Provider {
18 return &prometheusProvider{
24 // NewCounter implements Provider via prometheus.NewCounterFrom, i.e. the
25 // counter is registered. The metric's namespace and subsystem are taken from
26 // the Provider. Help is set to the name of the metric, and no const label names
28 func (p *prometheusProvider) NewCounter(name string) metrics.Counter {
29 return prometheus.NewCounterFrom(stdprometheus.CounterOpts{
30 Namespace: p.namespace,
31 Subsystem: p.subsystem,
37 // NewGauge implements Provider via prometheus.NewGaugeFrom, i.e. the gauge is
38 // registered. The metric's namespace and subsystem are taken from the Provider.
39 // Help is set to the name of the metric, and no const label names are set.
40 func (p *prometheusProvider) NewGauge(name string) metrics.Gauge {
41 return prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
42 Namespace: p.namespace,
43 Subsystem: p.subsystem,
49 // NewGauge implements Provider via prometheus.NewSummaryFrom, i.e. the summary
50 // is registered. The metric's namespace and subsystem are taken from the
51 // Provider. Help is set to the name of the metric, and no const label names are
52 // set. Buckets are ignored.
53 func (p *prometheusProvider) NewHistogram(name string, _ int) metrics.Histogram {
54 return prometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
55 Namespace: p.namespace,
56 Subsystem: p.subsystem,
62 // Stop implements Provider, but is a no-op.
63 func (p *prometheusProvider) Stop() {}