From bed9d1ae1cd47c1cb2c6af2a406390a3db353bf7 Mon Sep 17 00:00:00 2001 From: Gergely Madarasz Date: Fri, 6 Dec 2024 10:52:33 +0100 Subject: [PATCH] Test for metric unregistration --- exporter/exporterhelper/internal/queue_sender_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exporter/exporterhelper/internal/queue_sender_test.go b/exporter/exporterhelper/internal/queue_sender_test.go index 41dbbdbc38d..112b9bcc4b6 100644 --- a/exporter/exporterhelper/internal/queue_sender_test.go +++ b/exporter/exporterhelper/internal/queue_sender_test.go @@ -269,6 +269,10 @@ func TestQueuedRetry_QueueMetricsReported(t *testing.T) { attribute.String(DataTypeKey, dataType.String()))) assert.NoError(t, be.Shutdown(context.Background())) + // metrics should be unregistered at shutdown to prevent memory leak + require.Error(t, tt.CheckExporterMetricGauge("otelcol_exporter_queue_capacity", int64(defaultQueueSize))) + require.Error(t, tt.CheckExporterMetricGauge("otelcol_exporter_queue_size", int64(7), + attribute.String(DataTypeKey, dataType.String()))) } }) }