-
Notifications
You must be signed in to change notification settings - Fork 4
/
gauge_int64.go
62 lines (53 loc) · 2.17 KB
/
gauge_int64.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
58
59
60
61
62
package metrics
// MetricGaugeInt64 is just a gauge metric which stores the value as int64.
// It's an analog of "Gauge" metric of prometheus, see: https://prometheus.io/docs/concepts/metric_types/#gauge
type MetricGaugeInt64 struct {
commonInt64
}
func (r *Registry) newMetricGaugeInt64(key string, tags AnyTags) *MetricGaugeInt64 {
metric := metricGaugeInt64Pool.Get().(*MetricGaugeInt64)
metric.init(r, key, tags)
return metric
}
func (m *MetricGaugeInt64) init(r *Registry, key string, tags AnyTags) {
m.commonInt64.init(r, m, key, tags)
}
// GaugeInt64 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.
//
// MetricGaugeInt64 is just a gauge metric which stores the value as int64.
// It's an analog of "Gauge" metric of prometheus, see: https://prometheus.io/docs/concepts/metric_types/#gauge
func GaugeInt64(key string, tags AnyTags) *MetricGaugeInt64 {
return registry.GaugeInt64(key, tags)
}
// GaugeInt64 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.
//
// MetricGaugeInt64 is just a gauge metric which stores the value as int64.
// It's an analog of "Gauge" metric of prometheus, see: https://prometheus.io/docs/concepts/metric_types/#gauge
func (r *Registry) GaugeInt64(key string, tags AnyTags) *MetricGaugeInt64 {
if IsDisabled() {
return (*MetricGaugeInt64)(nil)
}
m := r.Get(TypeGaugeInt64, key, tags)
if m != nil {
return m.(*MetricGaugeInt64)
}
return r.newMetricGaugeInt64(key, tags)
}
// GetType always returns TypeGaugeInt64 (because of object type "MetricGaugeInt64")
func (m *MetricGaugeInt64) GetType() Type {
return TypeGaugeInt64
}
// Decrement is an analog of Add(-1). It just subtracts "1" from the internal value and returns the result.
func (m *MetricGaugeInt64) Decrement() int64 {
return m.Add(-1)
}