Skip to content

Commit

Permalink
Put metrics feature under a feature gate
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <[email protected]>
  • Loading branch information
rubenvp8510 committed Apr 16, 2024
1 parent 77cae28 commit c7cec54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
8 changes: 8 additions & 0 deletions pkg/featuregate/featuregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c7cec54

Please sign in to comment.