forked from kubevirt/cluster-network-addons-operator
/
gauge.go
36 lines (27 loc) · 726 Bytes
/
gauge.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 Gauge struct {
prometheus.Gauge
metricOpts MetricOpts
}
var _ Metric = &Gauge{}
// NewGauge creates a new Gauge. The Gauge must be registered with the
// Prometheus registry through RegisterMetrics.
func NewGauge(metricOpts MetricOpts) *Gauge {
return &Gauge{
Gauge: prometheus.NewGauge(prometheus.GaugeOpts(convertOpts(metricOpts))),
metricOpts: metricOpts,
}
}
func (c *Gauge) GetOpts() MetricOpts {
return c.metricOpts
}
func (c *Gauge) GetType() MetricType {
return GaugeType
}
func (c *Gauge) GetBaseType() MetricType {
return GaugeType
}
func (c *Gauge) getCollector() prometheus.Collector {
return c.Gauge
}