From 8e3f62b4b7bcc8a43713db0b9cc5f3186da57038 Mon Sep 17 00:00:00 2001 From: Oleksandr Didenko Date: Mon, 6 Nov 2023 11:37:15 +0100 Subject: [PATCH] Initialize success and error counters We need to initialize success and error counters properly in order to avoid having undefined metrics. Closes: #59 --- main.go | 4 +--- metrics.go | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index c416cff..c24f98d 100644 --- a/main.go +++ b/main.go @@ -35,7 +35,7 @@ import ( ) // Constants and vars -const version = "0.5.0" +const version = "0.5.1" const workersCannelSize = 1024 const errorBadHTTPCode = "Bad HTTP status code" @@ -516,9 +516,7 @@ func worker(ctx context.Context, id int, config appConfig, comm chan message, st } } else { - config.metrics.requestsSendSuccess.WithLabelValues(config.metrics.labelValues...).Inc() - } } } diff --git a/metrics.go b/metrics.go index c50cb47..a13aaae 100644 --- a/metrics.go +++ b/metrics.go @@ -329,6 +329,8 @@ func initMetrics(config appConfig, labelNames, labelValues []string) appMetrics am.channelConfigLength.WithLabelValues(labelValues...).Set(float64(workersCannelSize)) am.channelLength.WithLabelValues(labelValues...).Set(float64(0)) am.channelFullEvents.WithLabelValues(labelValues...).Add(0) + am.requestsSendSuccess.WithLabelValues(labelValues...).Add(0) + am.requestsSendErrors.WithLabelValues(labelValues...).Add(0) return am }