diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/BUILD b/staging/src/k8s.io/apiserver/pkg/storage/cacher/BUILD index 101aa352d76..1a479775050 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/BUILD @@ -5,6 +5,7 @@ go_library( srcs = [ "cacher.go", "caching_object.go", + "metrics.go", "time_budget.go", "util.go", "watch_cache.go", diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go index fbf644991ee..b09758d8e68 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go @@ -39,29 +39,11 @@ import ( "k8s.io/apiserver/pkg/storage" utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/tools/cache" - "k8s.io/component-base/metrics" - "k8s.io/component-base/metrics/legacyregistry" "k8s.io/klog" utiltrace "k8s.io/utils/trace" ) -/* - * By default, all the following metrics are defined as falling under - * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) - * - * Promoting the stability level of the metric is a responsibility of the component owner, since it - * involves explicitly acknowledging support for the metric across multiple releases, in accordance with - * the metric stability policy. - */ var ( - initCounter = metrics.NewCounterVec( - &metrics.CounterOpts{ - Name: "apiserver_init_events_total", - Help: "Counter of init events processed in watchcache broken by resource type", - StabilityLevel: metrics.ALPHA, - }, - []string{"resource"}, - ) emptyFunc = func() {} ) @@ -71,10 +53,6 @@ const ( storageWatchListPageSize = int64(10000) ) -func init() { - legacyregistry.MustRegister(initCounter) -} - // Config contains the configuration for a given Cache. type Config struct { // Maximum size of the history cached in memory. diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/metrics.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/metrics.go new file mode 100644 index 00000000000..0d6a0cdbf7c --- /dev/null +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/metrics.go @@ -0,0 +1,45 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cacher + +import ( + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" +) + +/* + * By default, all the following metrics are defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ +var ( + initCounter = metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "apiserver_init_events_total", + Help: "Counter of init events processed in watchcache broken by resource type", + StabilityLevel: metrics.ALPHA, + }, + []string{"resource"}, + ) +) + +func init() { + legacyregistry.MustRegister(initCounter) +}