From 8fe26526de2ed6e7c5d22bb1d624cb54de76f54e Mon Sep 17 00:00:00 2001 From: 321pranay Date: Fri, 24 May 2024 10:00:07 +0530 Subject: [PATCH] fix: panic for unknown topic metric (#76) --- metrics/prometheus.go | 2 +- metrics/prometheus_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/metrics/prometheus.go b/metrics/prometheus.go index 25aff9c5..2de6352d 100644 --- a/metrics/prometheus.go +++ b/metrics/prometheus.go @@ -152,7 +152,7 @@ func getCounterMap() map[string]CounterVec { Help: "Number of events received in requests"}, []string{"conn_group", "event_type"}) counters["kafka_unknown_topic_failure_total"] = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "kafka_unknown_topic_failure_total", - Help: "Number of delivery failure caused by topic does not exist in kafka."}, []string{"topic", "event_type"}) + Help: "Number of delivery failure caused by topic does not exist in kafka."}, []string{"topic", "event_type", "conn_group"}) counters["batches_read_total"] = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "batches_read_total", Help: "Request count"}, []string{"status", "reason", "conn_group"}) diff --git a/metrics/prometheus_test.go b/metrics/prometheus_test.go index ce459d97..13cdf33f 100644 --- a/metrics/prometheus_test.go +++ b/metrics/prometheus_test.go @@ -168,8 +168,8 @@ func (promSuite *PrometheusTestSuite) Test_Prometheus_Counter_Working() { mockCounter1 := mockCounter{} mockCounter2 := mockCounter{} callArg1 := int64(35) - labels1 := map[string]string{"topic": "test", "event_type": "abc"} - promLabels1 := prometheus.Labels{"topic": "test", "event_type": "abc"} + labels1 := map[string]string{"topic": "test", "event_type": "abc", "conn_group": "--default--"} + promLabels1 := prometheus.Labels{"topic": "test", "event_type": "abc", "conn_group": "--default--"} labels2 := map[string]string{"status": "success", "reason": "unknown", "conn_group": "abc"} promLabels2 := prometheus.Labels{"status": "success", "reason": "unknown", "conn_group": "abc"} var err error