Skip to content

Commit

Permalink
[chore][receiver/sapmreceiver] Enable goleak check (open-telemetry#31666
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.-->
Enable goleak checks on the sapm receiver to help ensure no goroutines
are being leaked. This is a test only change, some response bodies
weren't being closed in tests.

**Link to tracking Issue:** <Issue number if applicable>

open-telemetry#30438
  • Loading branch information
crobert-1 authored and DougManton committed Mar 13, 2024
1 parent 73ee3ba commit 4d2ddc8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions receiver/sapmreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ require (
go.opentelemetry.io/collector/semconv v0.96.1-0.20240306115632-b2693620eff6
go.opentelemetry.io/otel/metric v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
go.uber.org/goleak v1.3.0
)

require (
Expand Down
14 changes: 14 additions & 0 deletions receiver/sapmreceiver/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 sapmreceiver

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
2 changes: 2 additions & 0 deletions receiver/sapmreceiver/trace_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ func TestReception(t *testing.T) {
resp, err := sendSapm(tt.args.config.Endpoint, tt.args.sapm, tt.args.compression, tt.args.useTLS, "")
require.NoError(t, err)
assert.Equal(t, 200, resp.StatusCode)
assert.NoError(t, resp.Body.Close())
t.Log("SAPM Request Received")

// retrieve received traces
Expand Down Expand Up @@ -405,6 +406,7 @@ func TestAccessTokenPassthrough(t *testing.T) {
resp, err := sendSapm(config.Endpoint, sapm, "gzip", false, tt.token)
require.NoErrorf(t, err, "should not have failed when sending sapm %v", err)
assert.Equal(t, 200, resp.StatusCode)
assert.NoError(t, resp.Body.Close())

got := sink.AllTraces()
assert.Equal(t, 1, len(got))
Expand Down

0 comments on commit 4d2ddc8

Please sign in to comment.