diff --git a/staging/src/k8s.io/component-base/metrics/options.go b/staging/src/k8s.io/component-base/metrics/options.go index 087ea34b270..a782a16b62b 100644 --- a/staging/src/k8s.io/component-base/metrics/options.go +++ b/staging/src/k8s.io/component-base/metrics/options.go @@ -61,17 +61,18 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) { "disabled-metrics", o.DisabledMetrics, "This flag provides an escape hatch for misbehaving metrics. "+ - "You must provide the fully qualified metric name in order to disable it.") + "You must provide the fully qualified metric name in order to disable it. "+ + "Disclaimer: disabling metrics is higher in precedence than showing hidden metrics.") } // Apply applies parameters into global configuration of metrics. func (o *Options) Apply() { if o != nil && len(o.ShowHiddenMetricsForVersion) > 0 { SetShowHidden() - // set disabled metrics - for _, metricName := range o.DisabledMetrics { - SetDisabledMetric(metricName) - } + } + // set disabled metrics + for _, metricName := range o.DisabledMetrics { + SetDisabledMetric(metricName) } } diff --git a/staging/src/k8s.io/component-base/metrics/registry_test.go b/staging/src/k8s.io/component-base/metrics/registry_test.go index a6331b22f20..9a9da2bbb55 100644 --- a/staging/src/k8s.io/component-base/metrics/registry_test.go +++ b/staging/src/k8s.io/component-base/metrics/registry_test.go @@ -517,7 +517,9 @@ func TestRegistryReset(t *testing.T) { } func TestDisabledMetrics(t *testing.T) { - SetDisabledMetric("should_be_disabled") + o := NewOptions() + o.DisabledMetrics = []string{"should_be_disabled"} + o.Apply() currentVersion := apimachineryversion.Info{ Major: "1", Minor: "17",