/
summary.go
58 lines (47 loc) · 1.44 KB
/
summary.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 prommetrics
import (
"github.com/prometheus/client_golang/prometheus"
)
// Summary make an alias for non-decreasing numeric value.
type Summary prometheus.Summary
// SummaryVec interface to work with the Summary labelled.
type SummaryVec interface {
WithLabelValues(lvs ...string) prometheus.Observer
}
// summaryMethods
type summaryMethods interface {
NewSummary(subsystem, name, help string) Summary
NewSummaryVec(subsystem, name, help string, objectives map[float64]float64, labels ...string) SummaryVec
}
// NewSummary creates and wraps out 'current_summary_value_<of>' metrics.
func (m *metricsHandler) NewSummary(subsystem, name, help string) Summary {
metric := prometheus.NewSummary(
prometheus.SummaryOpts{
Namespace: m.metricsNamespace,
Subsystem: subsystem,
Name: name,
Help: help,
},
)
m.addMetricItem(subsystem, name, metric)
return metric
}
// NewSummaryVec creates and wraps out 'current_Summary_value_<of>' metrics with labels set.
func (m *metricsHandler) NewSummaryVec(subsystem, name, help string, objectives map[float64]float64, labels ...string) SummaryVec {
o := make(map[float64]float64)
for k, v := range objectives {
o[k] = v
}
metric := prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Namespace: m.metricsNamespace,
Subsystem: subsystem,
Name: name,
Help: help,
Objectives: o,
},
labels,
)
m.addMetricItem(subsystem, name, metric)
return metric
}