Skip to content

Commit a2161c1

Browse files
authored
Merge pull request kubernetes#86921 from mikedanese/metics
token cache: make fetch_total a counter
2 parents 3796176 + dc5934f commit a2161c1

File tree

1 file changed

+15
-10
lines changed
  • staging/src/k8s.io/apiserver/pkg/authentication/token/cache

1 file changed

+15
-10
lines changed

staging/src/k8s.io/apiserver/pkg/authentication/token/cache/stats.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,23 @@ var (
4242
},
4343
[]string{"status"},
4444
)
45-
fetchCount = metrics.NewGaugeVec(
46-
&metrics.GaugeOpts{
45+
fetchCount = metrics.NewCounterVec(
46+
&metrics.CounterOpts{
4747
Namespace: "authentication",
4848
Subsystem: "token_cache",
4949
Name: "fetch_total",
5050
StabilityLevel: metrics.ALPHA,
5151
},
5252
[]string{"status"},
5353
)
54-
blockCount = metrics.NewGauge(
54+
activeFetchCount = metrics.NewGaugeVec(
5555
&metrics.GaugeOpts{
5656
Namespace: "authentication",
5757
Subsystem: "token_cache",
58-
Name: "block_count",
58+
Name: "active_fetch_count",
5959
StabilityLevel: metrics.ALPHA,
6060
},
61+
[]string{"status"},
6162
)
6263
)
6364

@@ -66,17 +67,19 @@ func init() {
6667
requestLatency,
6768
requestCount,
6869
fetchCount,
69-
blockCount,
70+
activeFetchCount,
7071
)
7172
}
7273

7374
const (
7475
hitTag = "hit"
7576
missTag = "miss"
7677

77-
fetchActiveTag = "active"
7878
fetchFailedTag = "error"
7979
fetchOkTag = "ok"
80+
81+
fetchInFlightTag = "in_flight"
82+
fetchBlockedTag = "blocked"
8083
)
8184

8285
type statsCollector struct{}
@@ -101,12 +104,12 @@ func (statsCollector) authenticating() func(hit bool) {
101104
}
102105

103106
func (statsCollector) blocking() func() {
104-
blockCount.Inc()
105-
return blockCount.Dec
107+
activeFetchCount.WithLabelValues(fetchBlockedTag).Inc()
108+
return activeFetchCount.WithLabelValues(fetchBlockedTag).Dec
106109
}
107110

108111
func (statsCollector) fetching() func(ok bool) {
109-
fetchCount.WithLabelValues(fetchActiveTag).Inc()
112+
activeFetchCount.WithLabelValues(fetchInFlightTag).Inc()
110113
return func(ok bool) {
111114
var tag string
112115
if ok {
@@ -115,6 +118,8 @@ func (statsCollector) fetching() func(ok bool) {
115118
tag = fetchFailedTag
116119
}
117120

118-
fetchCount.WithLabelValues(tag).Dec()
121+
fetchCount.WithLabelValues(tag).Inc()
122+
123+
activeFetchCount.WithLabelValues(fetchInFlightTag).Dec()
119124
}
120125
}

0 commit comments

Comments
 (0)