From d45b0e3e36c579de66b69463151854ace9652b61 Mon Sep 17 00:00:00 2001 From: Pedro Tanaka Date: Mon, 23 Dec 2024 15:33:27 +0100 Subject: [PATCH] Keep track of metric names on the metric statsd_exporter_events_conflict_total Signed-off-by: Pedro Tanaka --- main.go | 2 +- pkg/exporter/exporter.go | 8 ++++---- pkg/exporter/exporter_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 688e6b16..2f139e61 100644 --- a/main.go +++ b/main.go @@ -148,7 +148,7 @@ var ( Name: "statsd_exporter_events_conflict_total", Help: "The total number of StatsD events with conflicting names.", }, - []string{"type"}, + []string{"type", "metric_name"}, ) errorEventStats = promauto.NewCounterVec( prometheus.CounterOpts{ diff --git a/pkg/exporter/exporter.go b/pkg/exporter/exporter.go index 134249e6..01206d06 100644 --- a/pkg/exporter/exporter.go +++ b/pkg/exporter/exporter.go @@ -137,7 +137,7 @@ func (b *Exporter) handleEvent(thisEvent event.Event) { b.EventStats.WithLabelValues("counter").Inc() } else { b.Logger.Debug(regErrF, "metric", metricName, "error", err) - b.ConflictingEventStats.WithLabelValues("counter").Inc() + b.ConflictingEventStats.WithLabelValues("counter", metricName).Inc() } case *event.GaugeEvent: @@ -152,7 +152,7 @@ func (b *Exporter) handleEvent(thisEvent event.Event) { b.EventStats.WithLabelValues("gauge").Inc() } else { b.Logger.Debug(regErrF, "metric", metricName, "error", err) - b.ConflictingEventStats.WithLabelValues("gauge").Inc() + b.ConflictingEventStats.WithLabelValues("gauge", metricName).Inc() } case *event.ObserverEvent: @@ -172,7 +172,7 @@ func (b *Exporter) handleEvent(thisEvent event.Event) { b.EventStats.WithLabelValues("observer").Inc() } else { b.Logger.Debug(regErrF, "metric", metricName, "error", err) - b.ConflictingEventStats.WithLabelValues("observer").Inc() + b.ConflictingEventStats.WithLabelValues("observer", metricName).Inc() } case mapper.ObserverTypeDefault, mapper.ObserverTypeSummary: @@ -182,7 +182,7 @@ func (b *Exporter) handleEvent(thisEvent event.Event) { b.EventStats.WithLabelValues("observer").Inc() } else { b.Logger.Debug(regErrF, "metric", metricName, "error", err) - b.ConflictingEventStats.WithLabelValues("observer").Inc() + b.ConflictingEventStats.WithLabelValues("observer", metricName).Inc() } default: diff --git a/pkg/exporter/exporter_test.go b/pkg/exporter/exporter_test.go index 8a8d153b..213949b5 100644 --- a/pkg/exporter/exporter_test.go +++ b/pkg/exporter/exporter_test.go @@ -117,7 +117,7 @@ var ( Name: "statsd_exporter_events_conflict_total", Help: "The total number of StatsD events with conflicting names.", }, - []string{"type"}, + []string{"type", "metric_name"}, ) errorEventStats = prometheus.NewCounterVec( prometheus.CounterOpts{