-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgauge_aggregative_simple.go
58 lines (49 loc) · 2.34 KB
/
gauge_aggregative_simple.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
package metrics
// MetricGaugeAggregativeSimple is an aggregative/summarizive metric (like "average", "percentile 99" and so on)..
// It's an analog of prometheus' "Summary" (see https://prometheus.io/docs/concepts/metric_types/#summary).
//
// MetricGaugeAggregativeSimple uses the "Simple" method to aggregate the statistics (see "Simple" in README.md)
type MetricGaugeAggregativeSimple struct {
commonAggregativeSimple
}
func (r *Registry) newMetricGaugeAggregativeSimple(key string, tags AnyTags) *MetricGaugeAggregativeSimple {
metric := metricGaugeAggregativeSimplePool.Get().(*MetricGaugeAggregativeSimple)
metric.init(r, key, tags)
return metric
}
func (m *MetricGaugeAggregativeSimple) init(r *Registry, key string, tags AnyTags) {
m.commonAggregativeSimple.init(r, m, key, tags)
}
// GaugeAggregativeSimple returns a metric of type "MetricGaugeAggregativeSimple".
//
// 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.
//
// MetricGaugeAggregativeSimple is an aggregative/summarizive metric (like "average", "percentile 99" and so on)..
// It's an analog of prometheus' "Summary" (see https://prometheus.io/docs/concepts/metric_types/#summary).
//
// MetricGaugeAggregativeSimple uses the "Simple" method to aggregate the statistics (see "Simple" in README.md)
func GaugeAggregativeSimple(key string, tags AnyTags) *MetricGaugeAggregativeSimple {
return registry.GaugeAggregativeSimple(key, tags)
}
func (r *Registry) GaugeAggregativeSimple(key string, tags AnyTags) *MetricGaugeAggregativeSimple {
if IsDisabled() {
return (*MetricGaugeAggregativeSimple)(nil)
}
m := r.Get(TypeGaugeAggregativeSimple, key, tags)
if m != nil {
return m.(*MetricGaugeAggregativeSimple)
}
return r.newMetricGaugeAggregativeSimple(key, tags)
}
// ConsiderValue adds a value to the statistics, it's an analog of prometheus' "Observe"
// (see https://godoc.org/github.com/prometheus/client_golang/prometheus#Summary)
func (m *MetricGaugeAggregativeSimple) ConsiderValue(v float64) {
m.considerValue(v)
}
// GetType always returns TypeGaugeAggregativeSimple (because of object type "MetricGaugeAggregativeSimple")
func (m *MetricGaugeAggregativeSimple) GetType() Type {
return TypeGaugeAggregativeSimple
}