Skip to content

Commit 2bbd885

Browse files
crobert-1mx-psi
andauthored
[chore][exporter/kafka] Enable goleak check (#30961)
**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 the `goleak` package to check the Kafka exporter for goroutine leaks. This is a test only change, a few `Shutdown` calls were missing from tests. **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 1d31b3f commit 2bbd885

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

exporter/kafkaexporter/factory_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ func TestCreateMetricExporter(t *testing.T) {
131131
}
132132
assert.NoError(t, err, "Must not error")
133133
assert.NotNil(t, exporter, "Must return valid exporter when no error is returned")
134+
assert.NoError(t, exporter.Shutdown(context.Background()))
134135
})
135136
}
136137
}
@@ -205,6 +206,7 @@ func TestCreateLogExporter(t *testing.T) {
205206
}
206207
assert.NoError(t, err, "Must not error")
207208
assert.NotNil(t, exporter, "Must return valid exporter when no error is returned")
209+
assert.NoError(t, exporter.Shutdown(context.Background()))
208210
})
209211
}
210212
}
@@ -279,6 +281,7 @@ func TestCreateTraceExporter(t *testing.T) {
279281
}
280282
assert.NoError(t, err, "Must not error")
281283
assert.NotNil(t, exporter, "Must return valid exporter when no error is returned")
284+
assert.NoError(t, exporter.Shutdown(context.Background()))
282285
})
283286
}
284287
}

exporter/kafkaexporter/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ require (
2424
go.opentelemetry.io/collector/semconv v0.95.0
2525
go.opentelemetry.io/otel/metric v1.23.1
2626
go.opentelemetry.io/otel/trace v1.23.1
27+
go.uber.org/goleak v1.3.0
2728
go.uber.org/multierr v1.11.0
2829
go.uber.org/zap v1.27.0
2930
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package kafkaexporter
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
func TestMain(m *testing.M) {
13+
goleak.VerifyTestMain(m)
14+
}

0 commit comments

Comments
 (0)