diff --git a/internal/e2e/go.mod b/internal/e2e/go.mod index 05f5d053711..7bc63308406 100644 --- a/internal/e2e/go.mod +++ b/internal/e2e/go.mod @@ -17,6 +17,7 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 go.opentelemetry.io/collector/receiver/otlpreceiver v0.91.0 + go.uber.org/goleak v1.3.0 ) require ( diff --git a/internal/e2e/go.sum b/internal/e2e/go.sum index 1b12213d829..b05ba6d2508 100644 --- a/internal/e2e/go.sum +++ b/internal/e2e/go.sum @@ -134,6 +134,7 @@ go.opentelemetry.io/otel/sdk/metric v1.21.0/go.mod h1:FJ8RAsoPGv/wYMgBdUJXOm+6pz go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= diff --git a/internal/e2e/otlphttp_test.go b/internal/e2e/otlphttp_test.go index f9bbcd3264e..b013ba0436b 100644 --- a/internal/e2e/otlphttp_test.go +++ b/internal/e2e/otlphttp_test.go @@ -250,6 +250,7 @@ func TestIssue_4221(t *testing.T) { spanID := span.SpanID() assert.Equal(t, "e5513c32795c41b9", hex.EncodeToString(spanID[:])) })) + defer func() { svr.Close() }() exp := startTracesExporter(t, "", svr.URL) diff --git a/internal/e2e/package_test.go b/internal/e2e/package_test.go new file mode 100644 index 00000000000..3d201f8d84d --- /dev/null +++ b/internal/e2e/package_test.go @@ -0,0 +1,17 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package e2e + +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")) +}