-
Notifications
You must be signed in to change notification settings - Fork 4
/
gauge_float64.go
57 lines (49 loc) · 2.06 KB
/
gauge_float64.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package metrics
// MetricGaugeFloat64 is just a gauge metric which stores the value as float64.
// It's an analog of "Gauge" metric of prometheus, see: https://prometheus.io/docs/concepts/metric_types/#gauge
type MetricGaugeFloat64 struct {
commonFloat64
}
func (r *Registry) newMetricGaugeFloat64(key string, tags AnyTags) *MetricGaugeFloat64 {
metric := metricGaugeFloat64Pool.Get().(*MetricGaugeFloat64)
metric.init(r, key, tags)
return metric
}
func (m *MetricGaugeFloat64) init(r *Registry, key string, tags AnyTags) {
m.commonFloat64.init(r, m, key, tags)
}
// GaugeFloat64 returns a metric of type "MetricGaugeFloat64".
//
// For the same key and tags it will return the same metric.
//
// If there's no such metric then it will create it, register it in the registry and return it.
// If there's already such metric then it will just return the metric.
//
// MetricGaugeFloat64 is just a gauge metric which stores the value as float64.
// It's an analog of "Gauge" metric of prometheus, see: https://prometheus.io/docs/concepts/metric_types/#gauge
func GaugeFloat64(key string, tags AnyTags) *MetricGaugeFloat64 {
return registry.GaugeFloat64(key, tags)
}
// GaugeFloat64 returns a metric of type "MetricGaugeFloat64".
//
// For the same key and tags it will return the same metric.
//
// If there's no such metric then it will create it, register it in the registry and return it.
// If there's already such metric then it will just return the metric.
//
// MetricGaugeFloat64 is just a gauge metric which stores the value as float64.
// It's an analog of "Gauge" metric of prometheus, see: https://prometheus.io/docs/concepts/metric_types/#gauge
func (r *Registry) GaugeFloat64(key string, tags AnyTags) *MetricGaugeFloat64 {
if IsDisabled() {
return (*MetricGaugeFloat64)(nil)
}
m := r.Get(TypeGaugeFloat64, key, tags)
if m != nil {
return m.(*MetricGaugeFloat64)
}
return r.newMetricGaugeFloat64(key, tags)
}
// GetType always returns TypeGaugeFloat64 (because of object type "MetricGaugeFloat64")
func (m *MetricGaugeFloat64) GetType() Type {
return TypeGaugeFloat64
}