From efc1735926e8e287918875f15a4e35bfc54ecf78 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Fri, 1 Mar 2024 11:51:25 -0800 Subject: [PATCH] [chore][exporter/logzioexporter] Enable goleak check (#31151) **Description:** This enables `goleak` checks in the Logz.io exporter to help ensure no goroutines are being leaked. This is a test only change as the only thing necessary was to add a missing close call on a server in a test. **Link to tracking Issue:** #30438 **Testing:** All existing tests are passing, as well as added `goleak` check. --- exporter/logzioexporter/go.mod | 1 + exporter/logzioexporter/jsonlog_test.go | 1 + exporter/logzioexporter/package_test.go | 14 ++++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 exporter/logzioexporter/package_test.go diff --git a/exporter/logzioexporter/go.mod b/exporter/logzioexporter/go.mod index 32759a6c3a90..297f01870f7a 100644 --- a/exporter/logzioexporter/go.mod +++ b/exporter/logzioexporter/go.mod @@ -20,6 +20,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/zap v1.27.0 google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 google.golang.org/protobuf v1.32.0 diff --git a/exporter/logzioexporter/jsonlog_test.go b/exporter/logzioexporter/jsonlog_test.go index 435c6159acec..6d75ceecc148 100644 --- a/exporter/logzioexporter/jsonlog_test.go +++ b/exporter/logzioexporter/jsonlog_test.go @@ -81,6 +81,7 @@ func TestSetTimeStamp(t *testing.T) { recordedRequests, _ = io.ReadAll(req.Body) rw.WriteHeader(http.StatusOK) })) + defer func() { server.Close() }() ld := generateLogsOneEmptyTimestamp() cfg := &Config{ Region: "us", diff --git a/exporter/logzioexporter/package_test.go b/exporter/logzioexporter/package_test.go new file mode 100644 index 000000000000..475e5299340f --- /dev/null +++ b/exporter/logzioexporter/package_test.go @@ -0,0 +1,14 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package logzioexporter + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +}