Add metric exposing amount of processed init events in watchcache

Kubernetes-commit: 0a0835e92dddf98208e84d3ca5661739b7ebf164
This commit is contained in:
wojtekt 2019-02-04 08:13:44 +01:00 committed by Kubernetes Publisher
parent 19ee6f1a72
commit 783162a9d2
1 changed files with 20 additions and 0 deletions

View File

@ -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.
@ -951,6 +967,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>"