@@ -42,22 +42,23 @@ var (
42
42
},
43
43
[]string {"status" },
44
44
)
45
- fetchCount = metrics .NewGaugeVec (
46
- & metrics.GaugeOpts {
45
+ fetchCount = metrics .NewCounterVec (
46
+ & metrics.CounterOpts {
47
47
Namespace : "authentication" ,
48
48
Subsystem : "token_cache" ,
49
49
Name : "fetch_total" ,
50
50
StabilityLevel : metrics .ALPHA ,
51
51
},
52
52
[]string {"status" },
53
53
)
54
- blockCount = metrics .NewGauge (
54
+ activeFetchCount = metrics .NewGaugeVec (
55
55
& metrics.GaugeOpts {
56
56
Namespace : "authentication" ,
57
57
Subsystem : "token_cache" ,
58
- Name : "block_count " ,
58
+ Name : "active_fetch_count " ,
59
59
StabilityLevel : metrics .ALPHA ,
60
60
},
61
+ []string {"status" },
61
62
)
62
63
)
63
64
@@ -66,17 +67,19 @@ func init() {
66
67
requestLatency ,
67
68
requestCount ,
68
69
fetchCount ,
69
- blockCount ,
70
+ activeFetchCount ,
70
71
)
71
72
}
72
73
73
74
const (
74
75
hitTag = "hit"
75
76
missTag = "miss"
76
77
77
- fetchActiveTag = "active"
78
78
fetchFailedTag = "error"
79
79
fetchOkTag = "ok"
80
+
81
+ fetchInFlightTag = "in_flight"
82
+ fetchBlockedTag = "blocked"
80
83
)
81
84
82
85
type statsCollector struct {}
@@ -101,12 +104,12 @@ func (statsCollector) authenticating() func(hit bool) {
101
104
}
102
105
103
106
func (statsCollector ) blocking () func () {
104
- blockCount .Inc ()
105
- return blockCount .Dec
107
+ activeFetchCount . WithLabelValues ( fetchBlockedTag ) .Inc ()
108
+ return activeFetchCount . WithLabelValues ( fetchBlockedTag ) .Dec
106
109
}
107
110
108
111
func (statsCollector ) fetching () func (ok bool ) {
109
- fetchCount .WithLabelValues (fetchActiveTag ).Inc ()
112
+ activeFetchCount .WithLabelValues (fetchInFlightTag ).Inc ()
110
113
return func (ok bool ) {
111
114
var tag string
112
115
if ok {
@@ -115,6 +118,8 @@ func (statsCollector) fetching() func(ok bool) {
115
118
tag = fetchFailedTag
116
119
}
117
120
118
- fetchCount .WithLabelValues (tag ).Dec ()
121
+ fetchCount .WithLabelValues (tag ).Inc ()
122
+
123
+ activeFetchCount .WithLabelValues (fetchInFlightTag ).Dec ()
119
124
}
120
125
}
0 commit comments