Skip to content

Commit 21bee24

Browse files
authored
[chore] Enable goleak for tests failing on opencensus-go (#30457)
**Description:** This enables `goleak` checks for all packages whose only failure is due to [a known issue](census-instrumentation/opencensus-go#1191) within the `opencensus-go` package. I believe it's safe to ignore for two main reasons: 1. All references that I'm aware of are indirect, the contrib repo isn't directly using the stat's worker functionality. The goroutine is started in the dependency's `init()` so it's not something that we're causing. 2. We're actively moving away from the opencensus dependency, and hope to remove it entirely soon. Relevant issue: open-telemetry/opentelemetry-collector#816. Once this work is complete the ignore will no longer be necessary and we can safely remove it. The only changes in this PR are test related. The same file is being copied into different packages, and then we run `make gotidy`. No functionality has been changed. **Link to tracking Issue:** #30438
1 parent 5a3a3ea commit 21bee24

File tree

463 files changed

+4142
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

463 files changed

+4142
-14
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package cfgmetadatagen
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}

cmd/configschema/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
go.opentelemetry.io/collector/config/configtls v0.93.1-0.20240125183026-3cacd40b27e8
1515
go.opentelemetry.io/collector/otelcol v0.93.1-0.20240125183026-3cacd40b27e8
1616
go.opentelemetry.io/collector/receiver/otlpreceiver v0.93.1-0.20240125183026-3cacd40b27e8
17+
go.uber.org/goleak v1.3.0
1718
golang.org/x/mod v0.14.0
1819
golang.org/x/text v0.14.0
1920
gopkg.in/yaml.v2 v2.4.0

cmd/configschema/go.sum

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
go.opentelemetry.io/collector/semconv v0.93.1-0.20240125183026-3cacd40b27e8
1414
go.opentelemetry.io/otel/metric v1.22.0
1515
go.opentelemetry.io/otel/trace v1.22.0
16+
go.uber.org/goleak v1.3.0
1617
go.uber.org/multierr v1.11.0
1718
go.uber.org/zap v1.26.0
1819
golang.org/x/text v0.14.0

cmd/mdatagen/go.sum

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package metadata
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}

connector/countconnector/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
go.opentelemetry.io/collector/pdata v1.0.2-0.20240125183026-3cacd40b27e8
1717
go.opentelemetry.io/otel/metric v1.22.0
1818
go.opentelemetry.io/otel/trace v1.22.0
19+
go.uber.org/goleak v1.3.0
1920
go.uber.org/zap v1.26.0
2021
)
2122

connector/countconnector/go.sum

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package countconnector
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}

connector/exceptionsconnector/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require (
1515
go.opentelemetry.io/collector/semconv v0.93.1-0.20240125183026-3cacd40b27e8
1616
go.opentelemetry.io/otel/metric v1.22.0
1717
go.opentelemetry.io/otel/trace v1.22.0
18+
go.uber.org/goleak v1.3.0
1819
go.uber.org/zap v1.26.0
1920
google.golang.org/grpc v1.60.1
2021
)

connector/exceptionsconnector/go.sum

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package exceptionsconnector
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}

connector/failoverconnector/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
go.opentelemetry.io/collector/pdata v1.0.2-0.20240125183026-3cacd40b27e8
1212
go.opentelemetry.io/otel/metric v1.22.0
1313
go.opentelemetry.io/otel/trace v1.22.0
14+
go.uber.org/goleak v1.3.0
1415
go.uber.org/zap v1.26.0
1516
)
1617

connector/failoverconnector/go.sum

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package failoverconnector
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}

connector/routingconnector/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
go.opentelemetry.io/collector/pdata v1.0.2-0.20240125183026-3cacd40b27e8
1313
go.opentelemetry.io/otel/metric v1.22.0
1414
go.opentelemetry.io/otel/trace v1.22.0
15+
go.uber.org/goleak v1.3.0
1516
go.uber.org/zap v1.26.0
1617
)
1718

connector/routingconnector/go.sum

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package routingconnector
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}

connector/servicegraphconnector/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
go.opentelemetry.io/collector/consumer v0.93.1-0.20240125183026-3cacd40b27e8
1212
go.opentelemetry.io/otel/metric v1.22.0
1313
go.opentelemetry.io/otel/trace v1.22.0
14+
go.uber.org/goleak v1.3.0
1415
)
1516

1617
require (

connector/servicegraphconnector/go.sum

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package servicegraphconnector
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package spanmetricsconnector
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package awskinesisexporter
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}

exporter/carbonexporter/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require (
1515
go.opentelemetry.io/collector/semconv v0.93.1-0.20240125183026-3cacd40b27e8
1616
go.opentelemetry.io/otel/metric v1.22.0
1717
go.opentelemetry.io/otel/trace v1.22.0
18+
go.uber.org/goleak v1.3.0
1819
go.uber.org/multierr v1.11.0
1920
)
2021

exporter/carbonexporter/go.sum

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package carbonexporter
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}

exporter/cassandraexporter/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
go.opentelemetry.io/collector/pdata v1.0.2-0.20240125183026-3cacd40b27e8
1414
go.opentelemetry.io/otel/metric v1.22.0
1515
go.opentelemetry.io/otel/trace v1.22.0
16+
go.uber.org/goleak v1.3.0
1617
go.uber.org/zap v1.26.0
1718
)
1819

exporter/cassandraexporter/go.sum

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package cassandraexporter
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package clickhouseexporter
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package clientutil
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package logs
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
// The IgnoreTopFunction call prevents catching the leak generated by opencensus
13+
// defaultWorker.Start which at this time is part of the package's init call.
14+
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
15+
func TestMain(m *testing.M) {
16+
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
17+
}

0 commit comments

Comments
 (0)