diff --git a/adapter/internal/adapter/adapter.go b/adapter/internal/adapter/adapter.go index 558cee7374..7671053dac 100644 --- a/adapter/internal/adapter/adapter.go +++ b/adapter/internal/adapter/adapter.go @@ -197,8 +197,8 @@ func Run(conf *config.Config) { }) } -logger.LoggerMgw.Info("Starting adapter ....") - + logger.LoggerMgw.Info("Starting adapter ....") + // Start the metrics server if conf.Adapter.Metrics.Enabled && strings.EqualFold(conf.Adapter.Metrics.Type, metrics.PrometheusMetricType) { logger.LoggerMgw.Info("Starting Prometheus Metrics Server ....") diff --git a/adapter/pkg/metrics/metrics.go b/adapter/pkg/metrics/metrics.go index 14326e0689..182946a0da 100644 --- a/adapter/pkg/metrics/metrics.go +++ b/adapter/pkg/metrics/metrics.go @@ -172,7 +172,13 @@ func handleError(err error, message string) bool { return false } -// StartPrometheusMetricsServer initializes and starts the metrics server to expose metrics to prometheus. +/* StartPrometheusMetricsServer initializes and starts the metrics server to expose metrics to prometheus. + It employs goroutines for concurrent execution of serving metrics and recording them, while ensuring + sequential execution for each recordMetrics call using a synchronization channel (done). + Parameters: + - port: The port number to listen on. + - collectionInterval: The interval for recording metrics. +*/ func StartPrometheusMetricsServer(port int32, collectionInterval int32) { done := make(chan struct{}) // Channel to indicate recordMetrics routine exit