Skip to content

Commit

Permalink
[chore][exporter/coralogixexporter] Enable goleak check
Browse files Browse the repository at this point in the history
  • Loading branch information
crobert-1 committed Feb 7, 2024
1 parent 1bb7923 commit 551fa0c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
15 changes: 12 additions & 3 deletions exporter/coralogixexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func TestTraceExporter(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, te, "failed to create trace exporter")
assert.NoError(t, te.start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, te.shutdown(context.Background()))
}

func TestMetricsExporter(t *testing.T) {
Expand All @@ -198,6 +199,7 @@ func TestMetricsExporter(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, me, "failed to create metrics exporter")
require.NoError(t, me.start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, me.shutdown(context.Background()))
}

func TestLogsExporter(t *testing.T) {
Expand All @@ -213,10 +215,11 @@ func TestLogsExporter(t *testing.T) {

params := exportertest.NewNopCreateSettings()

me, err := newLogsExporter(cfg, params)
le, err := newLogsExporter(cfg, params)
require.NoError(t, err)
require.NotNil(t, me, "failed to create logs exporter")
require.NoError(t, me.start(context.Background(), componenttest.NewNopHost()))
require.NotNil(t, le, "failed to create logs exporter")
require.NoError(t, le.start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, le.shutdown(context.Background()))
}

func TestDomainWithAllExporters(t *testing.T) {
Expand All @@ -234,16 +237,19 @@ func TestDomainWithAllExporters(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, te, "failed to create trace exporter")
assert.NoError(t, te.start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, te.shutdown(context.Background()))

me, err := newMetricsExporter(cfg, params)
require.NoError(t, err)
require.NotNil(t, me, "failed to create metrics exporter")
require.NoError(t, me.start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, me.shutdown(context.Background()))

le, err := newLogsExporter(cfg, params)
require.NoError(t, err)
require.NotNil(t, le, "failed to create logs exporter")
require.NoError(t, le.start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, le.shutdown(context.Background()))
}

func TestEndpoindsAndDomainWithAllExporters(t *testing.T) {
Expand All @@ -261,16 +267,19 @@ func TestEndpoindsAndDomainWithAllExporters(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, te, "failed to create trace exporter")
assert.NoError(t, te.start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, te.shutdown(context.Background()))

me, err := newMetricsExporter(cfg, params)
require.NoError(t, err)
require.NotNil(t, me, "failed to create metrics exporter")
require.NoError(t, me.start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, me.shutdown(context.Background()))

le, err := newLogsExporter(cfg, params)
require.NoError(t, err)
require.NotNil(t, le, "failed to create logs exporter")
require.NoError(t, le.start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, le.shutdown(context.Background()))
}

func TestGetMetadataFromResource(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions exporter/coralogixexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestCreateMetricsExporter(t *testing.T) {
oexp, err := factory.CreateMetricsExporter(context.Background(), set, cfg)
require.NoError(t, err)
require.NotNil(t, oexp)
require.NoError(t, oexp.Shutdown(context.Background()))
}

func TestCreateMetricsExporterWithDomain(t *testing.T) {
Expand All @@ -65,6 +66,7 @@ func TestCreateLogsExporter(t *testing.T) {
oexp, err := factory.CreateLogsExporter(context.Background(), set, cfg)
require.NoError(t, err)
require.NotNil(t, oexp)
require.NoError(t, oexp.Shutdown(context.Background()))
}

func TestCreateLogsExporterWithDomain(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions exporter/coralogixexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
go.opentelemetry.io/collector/pdata v1.1.0
go.opentelemetry.io/otel/metric v1.23.0
go.opentelemetry.io/otel/trace v1.23.0
go.uber.org/goleak v1.3.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1
google.golang.org/grpc v1.61.0
)
Expand Down
1 change: 1 addition & 0 deletions exporter/coralogixexporter/go.sum

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

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

package coralogixexporter

import (
"testing"

"go.uber.org/goleak"
)

// The IgnoreTopFunction call prevents catching the leak generated by opencensus
// defaultWorker.Start which at this time is part of the package's init call.
// See https://github.com/census-instrumentation/opencensus-go/issues/1191 for more information.
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
}

0 comments on commit 551fa0c

Please sign in to comment.