Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore][processor/batchprocessor] Enable goleak check #9224

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion processor/batchprocessor/batch_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ func TestBatchProcessorMetadataCardinalityLimit(t *testing.T) {

func TestBatchZeroConfig(t *testing.T) {
// This is a no-op configuration. No need for a timer, no
// minimum, no mxaimum, just a pass through.
// minimum, no maximum, just a pass through.
cfg := Config{}

require.NoError(t, cfg.Validate())
Expand All @@ -1047,6 +1047,7 @@ func TestBatchZeroConfig(t *testing.T) {
batcher, err := newBatchLogsProcessor(creationSet, sink, &cfg, false)
require.NoError(t, err)
require.NoError(t, batcher.Start(context.Background(), componenttest.NewNopHost()))
defer func() { require.NoError(t, batcher.Shutdown(context.Background())) }()

expect := 0
for requestNum := 0; requestNum < requestCount; requestNum++ {
Expand Down Expand Up @@ -1087,6 +1088,7 @@ func TestBatchSplitOnly(t *testing.T) {
batcher, err := newBatchLogsProcessor(creationSet, sink, &cfg, false)
require.NoError(t, err)
require.NoError(t, batcher.Start(context.Background(), componenttest.NewNopHost()))
defer func() { require.NoError(t, batcher.Shutdown(context.Background())) }()

for requestNum := 0; requestNum < requestCount; requestNum++ {
ld := testdata.GenerateLogs(logsPerRequest)
Expand Down
3 changes: 3 additions & 0 deletions processor/batchprocessor/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ func TestCreateProcessor(t *testing.T) {
tp, err := factory.CreateTracesProcessor(context.Background(), creationSet, cfg, nil)
assert.NotNil(t, tp)
assert.NoError(t, err, "cannot create trace processor")
assert.NoError(t, tp.Shutdown(context.Background()))

mp, err := factory.CreateMetricsProcessor(context.Background(), creationSet, cfg, nil)
assert.NotNil(t, mp)
assert.NoError(t, err, "cannot create metric processor")
assert.NoError(t, mp.Shutdown(context.Background()))

lp, err := factory.CreateLogsProcessor(context.Background(), creationSet, cfg, nil)
assert.NotNil(t, lp)
assert.NoError(t, err, "cannot create logs processor")
assert.NoError(t, lp.Shutdown(context.Background()))
}
1 change: 1 addition & 0 deletions processor/batchprocessor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
go.opentelemetry.io/otel/sdk v1.21.0
go.opentelemetry.io/otel/sdk/metric v1.21.0
go.opentelemetry.io/otel/trace v1.21.0
go.uber.org/goleak v1.3.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.26.0
)
Expand Down
1 change: 1 addition & 0 deletions processor/batchprocessor/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions processor/batchprocessor/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package batchprocessor

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"))
}
Loading