Skip to content

Commit 8ecf686

Browse files
authored
[chore][receiver/nginx] Enable goleak check (#32198)
Enable `goleak` check for the NGINX receiver to help ensure no goroutines are being leaked. This is a test only change, a couple test servers were missing `Close` calls. **Link to tracking Issue:** #30438
1 parent 4e413a7 commit 8ecf686

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
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 nginxreceiver
5+
6+
import (
7+
"testing"
8+
9+
"go.uber.org/goleak"
10+
)
11+
12+
func TestMain(m *testing.M) {
13+
goleak.VerifyTestMain(m)
14+
}

receiver/nginxreceiver/scraper_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424

2525
func TestScraper(t *testing.T) {
2626
nginxMock := newMockServer(t)
27+
defer nginxMock.Close()
28+
2729
cfg := createDefaultConfig().(*Config)
2830
cfg.Endpoint = nginxMock.URL + "/status"
2931
require.NoError(t, component.ValidateConfig(cfg))
@@ -79,6 +81,7 @@ func TestScraperError(t *testing.T) {
7981
_, err = sc.scrape(context.Background())
8082
require.ErrorContains(t, err, "Bad status page")
8183
})
84+
nginxMock.Close()
8285
}
8386

8487
func TestScraperFailedStart(t *testing.T) {

0 commit comments

Comments
 (0)