forked from kubevirt/cluster-network-addons-operator
/
counter.go
36 lines (27 loc) · 762 Bytes
/
counter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package operatormetrics
import "github.com/prometheus/client_golang/prometheus"
type Counter struct {
prometheus.Counter
metricOpts MetricOpts
}
var _ Metric = &Counter{}
// NewCounter creates a new Counter. The Counter must be registered with the
// Prometheus registry through RegisterMetrics.
func NewCounter(metricOpts MetricOpts) *Counter {
return &Counter{
Counter: prometheus.NewCounter(prometheus.CounterOpts(convertOpts(metricOpts))),
metricOpts: metricOpts,
}
}
func (c *Counter) GetOpts() MetricOpts {
return c.metricOpts
}
func (c *Counter) GetType() MetricType {
return CounterType
}
func (c *Counter) GetBaseType() MetricType {
return CounterType
}
func (c *Counter) getCollector() prometheus.Collector {
return c.Counter
}