...
1
2
3
4
5 package multi
6
7 import "github.com/go-kit/kit/metrics"
8
9
10 type Counter []metrics.Counter
11
12
13 func NewCounter(c ...metrics.Counter) Counter {
14 return Counter(c)
15 }
16
17
18 func (c Counter) Add(delta float64) {
19 for _, counter := range c {
20 counter.Add(delta)
21 }
22 }
23
24
25 func (c Counter) With(labelValues ...string) metrics.Counter {
26 next := make(Counter, len(c))
27 for i := range c {
28 next[i] = c[i].With(labelValues...)
29 }
30 return next
31 }
32
33
34 type Gauge []metrics.Gauge
35
36
37 func NewGauge(g ...metrics.Gauge) Gauge {
38 return Gauge(g)
39 }
40
41
42 func (g Gauge) Set(value float64) {
43 for _, gauge := range g {
44 gauge.Set(value)
45 }
46 }
47
48
49 func (g Gauge) With(labelValues ...string) metrics.Gauge {
50 next := make(Gauge, len(g))
51 for i := range g {
52 next[i] = g[i].With(labelValues...)
53 }
54 return next
55 }
56
57
58 func (g Gauge) Add(delta float64) {
59 for _, gauge := range g {
60 gauge.Add(delta)
61 }
62 }
63
64
65 type Histogram []metrics.Histogram
66
67
68 func NewHistogram(h ...metrics.Histogram) Histogram {
69 return Histogram(h)
70 }
71
72
73 func (h Histogram) Observe(value float64) {
74 for _, histogram := range h {
75 histogram.Observe(value)
76 }
77 }
78
79
80 func (h Histogram) With(labelValues ...string) metrics.Histogram {
81 next := make(Histogram, len(h))
82 for i := range h {
83 next[i] = h[i].With(labelValues...)
84 }
85 return next
86 }
87
View as plain text