diff --git a/adapter/config/types.go b/adapter/config/types.go index 6cda6a1cb3..d53eac1eda 100644 --- a/adapter/config/types.go +++ b/adapter/config/types.go @@ -302,10 +302,9 @@ type tracing struct { // Metrics defines the configuration for metrics collection. type Metrics struct { - Enabled bool - Type string - Port int32 - CollectionInterval int32 + Enabled bool + Type string + Port int32 } type analyticsAdapter struct { diff --git a/adapter/internal/operator/operator.go b/adapter/internal/operator/operator.go index d6e88f2dbf..151314fc50 100644 --- a/adapter/internal/operator/operator.go +++ b/adapter/internal/operator/operator.go @@ -107,6 +107,11 @@ func InitOperator(metricsConfig config.Metrics) { if metricsConfig.Enabled { options.Metrics.BindAddress = fmt.Sprintf(":%d", metricsConfig.Port) + // Register the metrics collector + if strings.EqualFold(metricsConfig.Type, metrics.PrometheusMetricType) { + loggers.LoggerAPKOperator.Info("Registering Prometheus metrics collector.") + metrics.RegisterPrometheusCollector() + } } else { options.Metrics.BindAddress = "0" } @@ -145,12 +150,6 @@ func InitOperator(metricsConfig config.Metrics) { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2603, logging.BLOCKER, "Unable to set up ready check: %v", err)) } - // Register the metrics collector - if metricsConfig.Enabled && strings.EqualFold(metricsConfig.Type, metrics.PrometheusMetricType) { - loggers.LoggerAPKOperator.Info("Registering Prometheus metrics collector.") - go metrics.RegisterPrometheusCollector() - } - go synchronizer.HandleAPILifeCycleEvents(&ch, &successChannel) go synchronizer.HandleGatewayLifeCycleEvents(&gatewaych) if config.ReadConfigs().PartitionServer.Enabled { diff --git a/common-controller/internal/config/types.go b/common-controller/internal/config/types.go index e724ec2445..ac30d12eee 100644 --- a/common-controller/internal/config/types.go +++ b/common-controller/internal/config/types.go @@ -107,10 +107,9 @@ type webServer struct { // Metrics defines the configuration for metrics collection. type Metrics struct { - Enabled bool - Type string - Port int32 - CollectionInterval int32 + Enabled bool + Type string + Port int32 } type database struct { diff --git a/common-controller/internal/operator/operator.go b/common-controller/internal/operator/operator.go index 8e33778822..25c87115e0 100644 --- a/common-controller/internal/operator/operator.go +++ b/common-controller/internal/operator/operator.go @@ -106,6 +106,12 @@ func InitOperator(metricsConfig config.Metrics) { if metricsConfig.Enabled { options.Metrics.BindAddress = fmt.Sprintf(":%d", metricsConfig.Port) + + // Register the metrics collector + if strings.EqualFold(metricsConfig.Type, metrics.PrometheusMetricType) { + loggers.LoggerAPKOperator.Info("Registering Prometheus metrics collector.") + metrics.RegisterPrometheusCollector() + } } else { options.Metrics.BindAddress = "0" } @@ -208,12 +214,6 @@ func InitOperator(metricsConfig config.Metrics) { }() } - // Register the metrics collector - if metricsConfig.Enabled && strings.EqualFold(metricsConfig.Type, metrics.PrometheusMetricType) { - loggers.LoggerAPKOperator.Info("Registering Prometheus metrics collector.") - go metrics.RegisterPrometheusCollector() - } - setupLog.Info("starting manager") if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2604, logging.BLOCKER, "Problem running manager: %v", err))