mirror of https://github.com/k3s-io/k3s
Add metric exposing amount of processed init events in watchcache
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/util/feature: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/utils/trace:go_default_library",
|
||||
],
|
||||
|
|
|
@ -41,8 +41,24 @@ import (
|
|||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
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.
|
||||
type Config struct {
|
||||
// Maximum size of the history cached in memory.
|
||||
|
@ -941,6 +957,10 @@ func (c *cacheWatcher) process(initEvents []*watchCacheEvent, resourceVersion ui
|
|||
for _, event := range initEvents {
|
||||
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)
|
||||
if processingTime > initProcessThreshold {
|
||||
objType := "<null>"
|
||||
|
|
|
@ -140,12 +140,7 @@ var InterestingApiServerMetrics = []string{
|
|||
// TODO(krzysied): apiserver_request_latencies_summary is a deprecated metric.
|
||||
// It should be replaced with new metric.
|
||||
"apiserver_request_latencies_summary",
|
||||
"etcd_helper_cache_entry_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",
|
||||
"apiserver_init_events_total",
|
||||
}
|
||||
|
||||
var InterestingControllerManagerMetrics = []string{
|
||||
|
|
Loading…
Reference in New Issue