Skip to content

Commit

Permalink
[chore][exporter/kafka] Enable goleak check (open-telemetry#30961)
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 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>
open-telemetry#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 <pbaeyens31+github@gmail.com>
  • Loading branch information
2 people authored and XinRanZhAWS committed Mar 13, 2024
1 parent 11de2ea commit e030a3b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions exporter/kafkaexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func TestCreateMetricExporter(t *testing.T) {
}
assert.NoError(t, err, "Must not error")
assert.NotNil(t, exporter, "Must return valid exporter when no error is returned")
assert.NoError(t, exporter.Shutdown(context.Background()))
})
}
}
Expand Down Expand Up @@ -205,6 +206,7 @@ func TestCreateLogExporter(t *testing.T) {
}
assert.NoError(t, err, "Must not error")
assert.NotNil(t, exporter, "Must return valid exporter when no error is returned")
assert.NoError(t, exporter.Shutdown(context.Background()))
})
}
}
Expand Down Expand Up @@ -279,6 +281,7 @@ func TestCreateTraceExporter(t *testing.T) {
}
assert.NoError(t, err, "Must not error")
assert.NotNil(t, exporter, "Must return valid exporter when no error is returned")
assert.NoError(t, exporter.Shutdown(context.Background()))
})
}
}
1 change: 1 addition & 0 deletions exporter/kafkaexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
go.opentelemetry.io/collector/semconv v0.95.0
go.opentelemetry.io/otel/metric v1.23.1
go.opentelemetry.io/otel/trace v1.23.1
go.uber.org/goleak v1.3.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
)
Expand Down
14 changes: 14 additions & 0 deletions exporter/kafkaexporter/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package kafkaexporter

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}

0 comments on commit e030a3b

Please sign in to comment.