From 2b7aade1b543df66a244f322cdb55a6e7defe337 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Mon, 29 Jan 2024 00:41:46 -0800 Subject: [PATCH] [chore][processor/cumulativetodeltaprocessor] Enable goleak check (#30804) **Description:** This enables the `goleak` check on all tests in this package, to ensure the processor isn't leaking goroutines. The only update here is in testing, as one test was missing a necessary `shutdown` call. **Link to tracking Issue:** #30438 **Testing:** All tests are passing, including added `goleak` check. --- .../cumulativetodeltaprocessor/factory_test.go | 1 + .../cumulativetodeltaprocessor/package_test.go | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 processor/cumulativetodeltaprocessor/package_test.go diff --git a/processor/cumulativetodeltaprocessor/factory_test.go b/processor/cumulativetodeltaprocessor/factory_test.go index 1a5fc624d80d..109244f970d9 100644 --- a/processor/cumulativetodeltaprocessor/factory_test.go +++ b/processor/cumulativetodeltaprocessor/factory_test.go @@ -62,6 +62,7 @@ func TestCreateProcessors(t *testing.T) { consumertest.NewNop()) assert.NotNil(t, mp) assert.NoError(t, mErr) + assert.NoError(t, mp.Shutdown(context.Background())) }) } } diff --git a/processor/cumulativetodeltaprocessor/package_test.go b/processor/cumulativetodeltaprocessor/package_test.go new file mode 100644 index 000000000000..00a5411fe5cc --- /dev/null +++ b/processor/cumulativetodeltaprocessor/package_test.go @@ -0,0 +1,17 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package cumulativetodeltaprocessor + +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/census-instrumentation/opencensus-go/issues/1191 for more information. +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start")) +}