-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgauge.go
50 lines (37 loc) · 932 Bytes
/
gauge.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
package stats
type GaugeVector interface {
WithLabels(...string) Gauge
}
type Gauge interface {
Update(int64)
Get() int64
}
type gaugeVector struct {
*atomicInt64Vector
}
func (gv gaugeVector) WithLabels(ls ...string) Gauge {
return gv.fetchValue(ls)
}
type partialGaugeVector struct {
gv GaugeVector
vs []string
}
func (pgv partialGaugeVector) WithLabels(ls ...string) Gauge {
return pgv.gv.WithLabels(append(pgv.vs, ls...)...)
}
type reorderGaugeVector struct {
gv GaugeVector
labelOrderer
}
func (rgv reorderGaugeVector) WithLabels(ls ...string) Gauge {
return rgv.gv.WithLabels(rgv.order(ls)...)
}
var (
NoopGauge Gauge = noopGauge{}
NoopGaugeVector GaugeVector = noopGaugeVector{}
)
type noopGauge struct{}
func (noopGauge) Update(int64) {}
func (noopGauge) Get() int64 { return 0 }
type noopGaugeVector struct{}
func (noopGaugeVector) WithLabels(...string) Gauge { return noopGauge{} }