diff --git a/exporter/exporterhelper/package_test.go b/exporter/exporterhelper/package_test.go new file mode 100644 index 00000000000..0980e46319f --- /dev/null +++ b/exporter/exporterhelper/package_test.go @@ -0,0 +1,17 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package exporterhelper + +import ( + "testing" + + "go.uber.org/goleak" +) + +// The IgnoreTopFunction call prevents catching the leak generated by opencensus +// defaultWorker.Start which at this time is part of the package's init call. +// See https://github.com/open-telemetry/opentelemetry-collector/issues/9165#issuecomment-1874836336 for more context. +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start")) +} diff --git a/exporter/exporterhelper/queue_sender_test.go b/exporter/exporterhelper/queue_sender_test.go index fe0633a605d..0af3c37b354 100644 --- a/exporter/exporterhelper/queue_sender_test.go +++ b/exporter/exporterhelper/queue_sender_test.go @@ -328,6 +328,7 @@ func TestQueuedRetryPersistentEnabled_NoDataLossOnShutdown(t *testing.T) { // wait for the item to be consumed from the queue replacedReq.checkNumRequests(t, 1) + require.NoError(t, be.Shutdown(context.Background())) } func TestQueueSenderNoStartShutdown(t *testing.T) {