Merge pull request #86921 from mikedanese/metics
token cache: make fetch_total a counter Kubernetes-commit: a2161c1349cccae5e2434e427d751a2f6f73266f
This commit is contained in:
commit
bcef75df7b
|
@ -42,8 +42,8 @@ var (
|
||||||
},
|
},
|
||||||
[]string{"status"},
|
[]string{"status"},
|
||||||
)
|
)
|
||||||
fetchCount = metrics.NewGaugeVec(
|
fetchCount = metrics.NewCounterVec(
|
||||||
&metrics.GaugeOpts{
|
&metrics.CounterOpts{
|
||||||
Namespace: "authentication",
|
Namespace: "authentication",
|
||||||
Subsystem: "token_cache",
|
Subsystem: "token_cache",
|
||||||
Name: "fetch_total",
|
Name: "fetch_total",
|
||||||
|
@ -51,13 +51,14 @@ var (
|
||||||
},
|
},
|
||||||
[]string{"status"},
|
[]string{"status"},
|
||||||
)
|
)
|
||||||
blockCount = metrics.NewGauge(
|
activeFetchCount = metrics.NewGaugeVec(
|
||||||
&metrics.GaugeOpts{
|
&metrics.GaugeOpts{
|
||||||
Namespace: "authentication",
|
Namespace: "authentication",
|
||||||
Subsystem: "token_cache",
|
Subsystem: "token_cache",
|
||||||
Name: "block_count",
|
Name: "active_fetch_count",
|
||||||
StabilityLevel: metrics.ALPHA,
|
StabilityLevel: metrics.ALPHA,
|
||||||
},
|
},
|
||||||
|
[]string{"status"},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ func init() {
|
||||||
requestLatency,
|
requestLatency,
|
||||||
requestCount,
|
requestCount,
|
||||||
fetchCount,
|
fetchCount,
|
||||||
blockCount,
|
activeFetchCount,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,9 +75,11 @@ const (
|
||||||
hitTag = "hit"
|
hitTag = "hit"
|
||||||
missTag = "miss"
|
missTag = "miss"
|
||||||
|
|
||||||
fetchActiveTag = "active"
|
|
||||||
fetchFailedTag = "error"
|
fetchFailedTag = "error"
|
||||||
fetchOkTag = "ok"
|
fetchOkTag = "ok"
|
||||||
|
|
||||||
|
fetchInFlightTag = "in_flight"
|
||||||
|
fetchBlockedTag = "blocked"
|
||||||
)
|
)
|
||||||
|
|
||||||
type statsCollector struct{}
|
type statsCollector struct{}
|
||||||
|
@ -101,12 +104,12 @@ func (statsCollector) authenticating() func(hit bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (statsCollector) blocking() func() {
|
func (statsCollector) blocking() func() {
|
||||||
blockCount.Inc()
|
activeFetchCount.WithLabelValues(fetchBlockedTag).Inc()
|
||||||
return blockCount.Dec
|
return activeFetchCount.WithLabelValues(fetchBlockedTag).Dec
|
||||||
}
|
}
|
||||||
|
|
||||||
func (statsCollector) fetching() func(ok bool) {
|
func (statsCollector) fetching() func(ok bool) {
|
||||||
fetchCount.WithLabelValues(fetchActiveTag).Inc()
|
activeFetchCount.WithLabelValues(fetchInFlightTag).Inc()
|
||||||
return func(ok bool) {
|
return func(ok bool) {
|
||||||
var tag string
|
var tag string
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -115,6 +118,8 @@ func (statsCollector) fetching() func(ok bool) {
|
||||||
tag = fetchFailedTag
|
tag = fetchFailedTag
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchCount.WithLabelValues(tag).Dec()
|
fetchCount.WithLabelValues(tag).Inc()
|
||||||
|
|
||||||
|
activeFetchCount.WithLabelValues(fetchInFlightTag).Dec()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue