Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore][exporter/splunkhecexporter] Enable goleak check #30968

Merged
merged 10 commits into from
Mar 8, 2024
15 changes: 9 additions & 6 deletions exporter/splunkhecexporter/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ func (c *capturingData) ServeHTTP(w http.ResponseWriter, r *http.Request) {
panic(err)
}
go func() {
c.receivedRequest <- receivedRequest{body, r.Header}
if c.receivedRequest != nil {
c.receivedRequest <- receivedRequest{body, r.Header}
}
}()
w.WriteHeader(c.statusCode)
}
Expand Down Expand Up @@ -1266,7 +1268,7 @@ func Test_PushMetricsData_Summary_NaN_Sum(t *testing.T) {
func TestReceiveMetricsWithCompression(t *testing.T) {
cfg := NewFactory().CreateDefaultConfig().(*Config)
cfg.MaxContentLengthMetrics = 1800
request, err := runMetricsExport(cfg, createMetricsData(1, 100), 1, false, t)
request, err := runMetricsExport(cfg, createMetricsData(1, 100), 2, false, t)
crobert-1 marked this conversation as resolved.
Show resolved Hide resolved
assert.NoError(t, err)
assert.Equal(t, "gzip", request[0].headers.Get("Content-Encoding"))
assert.NotEqual(t, "", request)
Expand Down Expand Up @@ -1363,8 +1365,7 @@ func TestInvalidURL(t *testing.T) {
}

func TestHeartbeatStartupFailed(t *testing.T) {
rr := make(chan receivedRequest)
capture := capturingData{receivedRequest: rr, statusCode: 403}
capture := capturingData{statusCode: 403}
listener, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
panic(err)
Expand Down Expand Up @@ -1398,6 +1399,7 @@ func TestHeartbeatStartupFailed(t *testing.T) {
exporter.Start(context.Background(), componenttest.NewNopHost()),
fmt.Sprintf("%s: heartbeat on startup failed: HTTP 403 \"Forbidden\"", params.ID.Type()),
)
assert.NoError(t, exporter.Shutdown(context.Background()))
}

func TestHeartbeatStartupPass_Disabled(t *testing.T) {
Expand Down Expand Up @@ -1433,11 +1435,11 @@ func TestHeartbeatStartupPass_Disabled(t *testing.T) {
exporter, err := factory.CreateTracesExporter(context.Background(), params, cfg)
assert.NoError(t, err)
assert.NoError(t, exporter.Start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, exporter.Shutdown(context.Background()))
}

func TestHeartbeatStartupPass(t *testing.T) {
rr := make(chan receivedRequest)
capture := capturingData{receivedRequest: rr, statusCode: 200}
capture := capturingData{statusCode: 200}
listener, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
panic(err)
Expand Down Expand Up @@ -1468,6 +1470,7 @@ func TestHeartbeatStartupPass(t *testing.T) {
exporter, err := factory.CreateTracesExporter(context.Background(), params, cfg)
assert.NoError(t, err)
assert.NoError(t, exporter.Start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, exporter.Shutdown(context.Background()))
}

type badJSON struct {
Expand Down
1 change: 1 addition & 0 deletions exporter/splunkhecexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
gopkg.in/yaml.v3 v3.0.1
Expand Down
Loading
Loading