diff options
Diffstat (limited to 'service/metrics/config.go')
-rw-r--r-- | service/metrics/config.go | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/service/metrics/config.go b/service/metrics/config.go index 341d0c70..bee4f3d1 100644 --- a/service/metrics/config.go +++ b/service/metrics/config.go @@ -23,6 +23,23 @@ type NamedCollector struct { Collector } +// CollectorType represents prometheus collector types +type CollectorType string + +const ( + // Histogram type + Histogram CollectorType = "histogram" + + // Gauge type + Gauge CollectorType = "gauge" + + // Counter type + Counter CollectorType = "counter" + + // Summary type + Summary CollectorType = "summary" +) + // Collector describes single application specific metric. type Collector struct { // Namespace of the metric. @@ -32,7 +49,7 @@ type Collector struct { Subsystem string // Collector type (histogram, gauge, counter, summary). - Type string + Type CollectorType // Help of collector. Help string @@ -60,7 +77,7 @@ func (c *Config) getCollectors() (map[string]prometheus.Collector, error) { for name, m := range c.Collect { var collector prometheus.Collector switch m.Type { - case "histogram": + case Histogram: opts := prometheus.HistogramOpts{ Name: name, Namespace: m.Namespace, @@ -74,7 +91,7 @@ func (c *Config) getCollectors() (map[string]prometheus.Collector, error) { } else { collector = prometheus.NewHistogram(opts) } - case "gauge": + case Gauge: opts := prometheus.GaugeOpts{ Name: name, Namespace: m.Namespace, @@ -87,7 +104,7 @@ func (c *Config) getCollectors() (map[string]prometheus.Collector, error) { } else { collector = prometheus.NewGauge(opts) } - case "counter": + case Counter: opts := prometheus.CounterOpts{ Name: name, Namespace: m.Namespace, @@ -100,7 +117,7 @@ func (c *Config) getCollectors() (map[string]prometheus.Collector, error) { } else { collector = prometheus.NewCounter(opts) } - case "summary": + case Summary: opts := prometheus.SummaryOpts{ Name: name, Namespace: m.Namespace, |