Skip to content

Commit

Permalink
[chore][receiver/sqlquery] Enable goleak check (open-telemetry#31667)
Browse files Browse the repository at this point in the history
**Description:** 
Enable goleak checks to help ensure no goroutines are being leaked. This
is a test only change, a couple tests were missing `Shutdown` calls.

**Link to tracking Issue:**
open-telemetry#30438

---------

Co-authored-by: Andrzej Stencel <[email protected]>
  • Loading branch information
crobert-1 and andrzej-stencel authored Mar 12, 2024
1 parent da8ab18 commit 2a638ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions receiver/sqlqueryreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
go.opentelemetry.io/collector/receiver v0.96.1-0.20240306115632-b2693620eff6
go.opentelemetry.io/otel/metric v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
go.uber.org/goleak v1.3.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
)
Expand Down
15 changes: 15 additions & 0 deletions receiver/sqlqueryreceiver/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package sqlqueryreceiver

import (
"testing"

"go.uber.org/goleak"
)

// Regarding the godbus/dbus ignore: see https://github.com/99designs/keyring/issues/103
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m, goleak.IgnoreAnyFunction("github.com/godbus/dbus.(*Conn).inWorker"))
}
2 changes: 2 additions & 0 deletions receiver/sqlqueryreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestCreateLogsReceiver(t *testing.T) {
require.NoError(t, err)
err = receiver.Start(ctx, componenttest.NewNopHost())
require.NoError(t, err)
require.NoError(t, receiver.Shutdown(ctx))
}

func TestCreateMetricsReceiver(t *testing.T) {
Expand Down Expand Up @@ -75,6 +76,7 @@ func TestCreateMetricsReceiver(t *testing.T) {
require.NoError(t, err)
err = receiver.Start(ctx, componenttest.NewNopHost())
require.NoError(t, err)
require.NoError(t, receiver.Shutdown(ctx))
}

func fakeDBConnect(string, string) (*sql.DB, error) {
Expand Down

0 comments on commit 2a638ec

Please sign in to comment.