Skip to content

Commit

Permalink
[chore][receiver/namedpipe] Enable goleak check (#32200)
Browse files Browse the repository at this point in the history
**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
Add `goleak` check to the namedpipe receiver to help ensure no
goroutines are being leaked.

**Link to tracking Issue:** <Issue number if applicable>
#30438

**Testing:** <Describe what testing was performed and which tests were
added.>
None yet, I'm running on macOS and this is a Linux-only receiver.
Relying on GitHub CI/CD to show results. I'll convert this to ready to
review if it passes.
  • Loading branch information
crobert-1 authored Apr 16, 2024
1 parent ce92d2e commit 51677d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions receiver/namedpipereceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
go.opentelemetry.io/collector/receiver v0.98.1-0.20240412014414-62f589864e3d
go.opentelemetry.io/otel/metric v1.25.0
go.opentelemetry.io/otel/trace v1.25.0
go.uber.org/goleak v1.3.0
go.uber.org/zap v1.27.0
)

Expand Down
1 change: 1 addition & 0 deletions receiver/namedpipereceiver/namedpipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func TestReadPipe(t *testing.T) {
rcvr, err := f.CreateLogsReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, sink)
require.NoError(t, err, "failed to create receiver")
require.NoError(t, rcvr.Start(context.Background(), componenttest.NewNopHost()))
defer func() { require.NoError(t, rcvr.Shutdown(context.Background())) }()

pipe, err := os.OpenFile("/tmp/pipe", os.O_WRONLY, 0o600)
require.NoError(t, err, "failed to open pipe")
Expand Down
14 changes: 14 additions & 0 deletions receiver/namedpipereceiver/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package namedpipereceiver

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}

0 comments on commit 51677d3

Please sign in to comment.