From 23cf1e4fa69bea0a188af0ed78d8af810f8ec062 Mon Sep 17 00:00:00 2001 From: Avishka-Shamendra Date: Tue, 5 Mar 2024 18:21:15 +0530 Subject: [PATCH] Fix minor code styling changes --- adapter/internal/adapter/adapter.go | 4 ++-- adapter/pkg/metrics/metrics.go | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) 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