Skip to content

Commit 1d31b3f

Browse files
crobert-1mx-psi
andauthored
[chore][exporter/prometheusremotewriteexporter] Enable goleak check (#30966)
**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` checks for the prometheusremotewrite exporter, to help ensure no goroutines are being leaked. This is a test only change, the only update is to add a missing `Shutdown` call. **Link to tracking Issue:** <Issue number if applicable> #30438 **Testing:** <Describe what testing was performed and which tests were added.> All existing tests are passing, as well as added `goleak` check. --------- Co-authored-by: Pablo Baeyens <[email protected]>
1 parent 467a93e commit 1d31b3f

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

exporter/prometheusremotewriteexporter/factory_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func Test_createMetricsExporter(t *testing.T) {
8686
return
8787
}
8888
assert.NoError(t, err)
89+
assert.NoError(t, exp.Shutdown(context.Background()))
8990
})
9091
}
9192
}

exporter/prometheusremotewriteexporter/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ require (
2525
go.opentelemetry.io/collector/pdata v1.2.0
2626
go.opentelemetry.io/otel/metric v1.23.1
2727
go.opentelemetry.io/otel/trace v1.23.1
28+
go.uber.org/goleak v1.3.0
2829
go.uber.org/multierr v1.11.0
2930
go.uber.org/zap v1.27.0
3031
)
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 prometheusremotewriteexporter
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)
17+
}

0 commit comments

Comments
 (0)