diff --git a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/stats.go b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/stats.go index 50f01395920..dbe745718e7 100644 --- a/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/stats.go +++ b/staging/src/k8s.io/apiserver/pkg/authentication/token/cache/stats.go @@ -42,8 +42,8 @@ var ( }, []string{"status"}, ) - fetchCount = metrics.NewGaugeVec( - &metrics.GaugeOpts{ + fetchCount = metrics.NewCounterVec( + &metrics.CounterOpts{ Namespace: "authentication", Subsystem: "token_cache", Name: "fetch_total", @@ -51,13 +51,14 @@ var ( }, []string{"status"}, ) - blockCount = metrics.NewGauge( + activeFetchCount = metrics.NewGaugeVec( &metrics.GaugeOpts{ Namespace: "authentication", Subsystem: "token_cache", - Name: "block_count", + Name: "active_fetch_count", StabilityLevel: metrics.ALPHA, }, + []string{"status"}, ) ) @@ -66,7 +67,7 @@ func init() { requestLatency, requestCount, fetchCount, - blockCount, + activeFetchCount, ) } @@ -74,9 +75,11 @@ const ( hitTag = "hit" missTag = "miss" - fetchActiveTag = "active" fetchFailedTag = "error" fetchOkTag = "ok" + + fetchInFlightTag = "in_flight" + fetchBlockedTag = "blocked" ) type statsCollector struct{} @@ -101,12 +104,12 @@ func (statsCollector) authenticating() func(hit bool) { } func (statsCollector) blocking() func() { - blockCount.Inc() - return blockCount.Dec + activeFetchCount.WithLabelValues(fetchBlockedTag).Inc() + return activeFetchCount.WithLabelValues(fetchBlockedTag).Dec } func (statsCollector) fetching() func(ok bool) { - fetchCount.WithLabelValues(fetchActiveTag).Inc() + activeFetchCount.WithLabelValues(fetchInFlightTag).Inc() return func(ok bool) { var tag string if ok { @@ -115,6 +118,8 @@ func (statsCollector) fetching() func(ok bool) { tag = fetchFailedTag } - fetchCount.WithLabelValues(tag).Dec() + fetchCount.WithLabelValues(tag).Inc() + + activeFetchCount.WithLabelValues(fetchInFlightTag).Dec() } }