mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Add metric exposing amount of processed init events in watchcache
This commit is contained in:
parent
999e2e0ce8
commit
0a0835e92d
@ -27,6 +27,7 @@ go_library(
|
|||||||
"//staging/src/k8s.io/apiserver/pkg/storage:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/storage:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||||
|
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
|
||||||
"//vendor/k8s.io/klog:go_default_library",
|
"//vendor/k8s.io/klog:go_default_library",
|
||||||
"//vendor/k8s.io/utils/trace:go_default_library",
|
"//vendor/k8s.io/utils/trace:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -41,8 +41,24 @@ import (
|
|||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
utiltrace "k8s.io/utils/trace"
|
utiltrace "k8s.io/utils/trace"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
initCounter = prometheus.NewCounterVec(
|
||||||
|
prometheus.CounterOpts{
|
||||||
|
Name: "apiserver_init_events_total",
|
||||||
|
Help: "Counter of init events processed in watchcache broken by resource type",
|
||||||
|
},
|
||||||
|
[]string{"resource"},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
prometheus.MustRegister(initCounter)
|
||||||
|
}
|
||||||
|
|
||||||
// Config contains the configuration for a given Cache.
|
// Config contains the configuration for a given Cache.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Maximum size of the history cached in memory.
|
// Maximum size of the history cached in memory.
|
||||||
@ -941,6 +957,10 @@ func (c *cacheWatcher) process(initEvents []*watchCacheEvent, resourceVersion ui
|
|||||||
for _, event := range initEvents {
|
for _, event := range initEvents {
|
||||||
c.sendWatchCacheEvent(event)
|
c.sendWatchCacheEvent(event)
|
||||||
}
|
}
|
||||||
|
if len(initEvents) > 0 {
|
||||||
|
objType := reflect.TypeOf(initEvents[0].Object).String()
|
||||||
|
initCounter.WithLabelValues(objType).Add(float64(len(initEvents)))
|
||||||
|
}
|
||||||
processingTime := time.Since(startTime)
|
processingTime := time.Since(startTime)
|
||||||
if processingTime > initProcessThreshold {
|
if processingTime > initProcessThreshold {
|
||||||
objType := "<null>"
|
objType := "<null>"
|
||||||
|
@ -140,12 +140,7 @@ var InterestingApiServerMetrics = []string{
|
|||||||
// TODO(krzysied): apiserver_request_latencies_summary is a deprecated metric.
|
// TODO(krzysied): apiserver_request_latencies_summary is a deprecated metric.
|
||||||
// It should be replaced with new metric.
|
// It should be replaced with new metric.
|
||||||
"apiserver_request_latencies_summary",
|
"apiserver_request_latencies_summary",
|
||||||
"etcd_helper_cache_entry_total",
|
"apiserver_init_events_total",
|
||||||
"etcd_helper_cache_hit_total",
|
|
||||||
"etcd_helper_cache_miss_total",
|
|
||||||
"etcd_request_cache_add_latency_seconds",
|
|
||||||
"etcd_request_cache_get_latency_seconds",
|
|
||||||
"etcd_request_latency_seconds",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var InterestingControllerManagerMetrics = []string{
|
var InterestingControllerManagerMetrics = []string{
|
||||||
|
Loading…
Reference in New Issue
Block a user