Skip to content

Commit 8fa7931

Browse files
authored
Merge pull request kubernetes#90200 from gongguan/capacity-metric
move watchCache metrics to a seperate file
2 parents b0806d0 + 21ba510 commit 8fa7931

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

staging/src/k8s.io/apiserver/pkg/storage/cacher/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go_library(
55
srcs = [
66
"cacher.go",
77
"caching_object.go",
8+
"metrics.go",
89
"time_budget.go",
910
"util.go",
1011
"watch_cache.go",

staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,11 @@ import (
3939
"k8s.io/apiserver/pkg/storage"
4040
utilfeature "k8s.io/apiserver/pkg/util/feature"
4141
"k8s.io/client-go/tools/cache"
42-
"k8s.io/component-base/metrics"
43-
"k8s.io/component-base/metrics/legacyregistry"
4442
"k8s.io/klog"
4543
utiltrace "k8s.io/utils/trace"
4644
)
4745

48-
/*
49-
* By default, all the following metrics are defined as falling under
50-
* ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes)
51-
*
52-
* Promoting the stability level of the metric is a responsibility of the component owner, since it
53-
* involves explicitly acknowledging support for the metric across multiple releases, in accordance with
54-
* the metric stability policy.
55-
*/
5646
var (
57-
initCounter = metrics.NewCounterVec(
58-
&metrics.CounterOpts{
59-
Name: "apiserver_init_events_total",
60-
Help: "Counter of init events processed in watchcache broken by resource type",
61-
StabilityLevel: metrics.ALPHA,
62-
},
63-
[]string{"resource"},
64-
)
6547
emptyFunc = func() {}
6648
)
6749

@@ -71,10 +53,6 @@ const (
7153
storageWatchListPageSize = int64(10000)
7254
)
7355

74-
func init() {
75-
legacyregistry.MustRegister(initCounter)
76-
}
77-
7856
// Config contains the configuration for a given Cache.
7957
type Config struct {
8058
// Maximum size of the history cached in memory.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package cacher
18+
19+
import (
20+
"k8s.io/component-base/metrics"
21+
"k8s.io/component-base/metrics/legacyregistry"
22+
)
23+
24+
/*
25+
* By default, all the following metrics are defined as falling under
26+
* ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes)
27+
*
28+
* Promoting the stability level of the metric is a responsibility of the component owner, since it
29+
* involves explicitly acknowledging support for the metric across multiple releases, in accordance with
30+
* the metric stability policy.
31+
*/
32+
var (
33+
initCounter = metrics.NewCounterVec(
34+
&metrics.CounterOpts{
35+
Name: "apiserver_init_events_total",
36+
Help: "Counter of init events processed in watchcache broken by resource type",
37+
StabilityLevel: metrics.ALPHA,
38+
},
39+
[]string{"resource"},
40+
)
41+
)
42+
43+
func init() {
44+
legacyregistry.MustRegister(initCounter)
45+
}

0 commit comments

Comments
 (0)