diff --git a/main.go b/main.go index b5f273c674..5ea34c9b82 100644 --- a/main.go +++ b/main.go @@ -296,9 +296,10 @@ func main() { setupLog.Error(clientErr, "failed to create kubernetes clientset") } reviewer := rbac.NewReviewer(clientset) - - if metricsErr := crdmetrics.Bootstrap(mgr.GetClient()); metricsErr != nil { - setupLog.Error(metricsErr, "Error bootstrapping CRD metrics") + if featuregate.EnableCRMetrics.IsEnabled() { + if metricsErr := crdmetrics.Bootstrap(mgr.GetClient()); metricsErr != nil { + setupLog.Error(metricsErr, "Error bootstrapping CRD metrics") + } } if err = controllers.NewReconciler(controllers.Params{ diff --git a/pkg/featuregate/featuregate.go b/pkg/featuregate/featuregate.go index a20d589b35..19ef595fc9 100644 --- a/pkg/featuregate/featuregate.go +++ b/pkg/featuregate/featuregate.go @@ -60,6 +60,14 @@ var ( featuregate.WithRegisterDescription("enables features associated to the Prometheus Operator"), featuregate.WithRegisterFromVersion("v0.82.0"), ) + + // EnableCRMetrics is the feature gate that enables metrics about the collectors managed by this operator. + EnableCRMetrics = featuregate.GlobalRegistry().MustRegister( + "operator.crmetrics", + featuregate.StageBeta, + featuregate.WithRegisterDescription("enables metrics about the collectors CRs and how they are used"), + featuregate.WithRegisterFromVersion("v0.99.0"), + ) ) // Flags creates a new FlagSet that represents the available featuregate flags using the supplied featuregate registry.