Skip to content

Commit

Permalink
[chore][exporter/fileexporter] Enable goleak check (open-telemetry#30899
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.-->
This enables `goleak` to check for any leaking goroutines in this
package. There is an existing goleak, but it's in a third party
dependency which we cannot resolve on our end. There's been a [PR open
for this issue](natefinch/lumberjack#57) for 6
years and it hasn't been merged.

**Note:** The `natefinch/lumberjack` package is now unmaintained, so
this will likely never be fixed. We should consider moving to a new
package if possible to avoid the leak. I'll defer to code owners for
feedback on possible options.

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

**Testing:** <Describe what testing was performed and which tests were
added.>
Existing tests and added goleak check are passing.
  • Loading branch information
crobert-1 authored and cparkins committed Feb 1, 2024
1 parent 4a24b2d commit 3c6b4d5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions exporter/fileexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
go.opentelemetry.io/collector/pdata v1.0.2-0.20240130181942-9c7177496fd5
go.opentelemetry.io/otel/metric v1.22.0
go.opentelemetry.io/otel/trace v1.22.0
go.uber.org/goleak v1.3.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)

Expand Down
1 change: 1 addition & 0 deletions exporter/fileexporter/go.sum

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

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

package fileexporter

import (
"testing"

"go.uber.org/goleak"
)

// The IgnoreTopFunction call prevents catching the leak generated by the natefinch/lumberjack package.
// Existing issue for leak: https://github.com/natefinch/lumberjack/issues/56
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun"))
}

0 comments on commit 3c6b4d5

Please sign in to comment.