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] close http responses and preallocate slices #24926

Merged
merged 5 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions receiver/signalfxreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ func Test_sfxReceiver_handleReq(t *testing.T) {

resp := w.Result()
respBytes, err := io.ReadAll(resp.Body)
defer resp.Body.Close()
assert.NoError(t, err)

var bodyStr string
Expand Down Expand Up @@ -521,6 +522,7 @@ func Test_sfxReceiver_handleEventReq(t *testing.T) {
resp := w.Result()
respBytes, err := io.ReadAll(resp.Body)
assert.NoError(t, err)
defer resp.Body.Close()

var bodyStr string
assert.NoError(t, json.Unmarshal(respBytes, &bodyStr))
Expand Down Expand Up @@ -600,6 +602,7 @@ func Test_sfxReceiver_TLS(t *testing.T) {

resp, err := client.Do(req)
require.NoErrorf(t, err, "should not have failed when sending to signalFx receiver %v", err)
defer resp.Body.Close()
assert.Equal(t, http.StatusOK, resp.StatusCode)
t.Log("SignalFx Request Received")

Expand Down Expand Up @@ -664,6 +667,7 @@ func Test_sfxReceiver_DatapointAccessTokenPassthrough(t *testing.T) {
resp := w.Result()
respBytes, err := io.ReadAll(resp.Body)
assert.NoError(t, err)
defer resp.Body.Close()

var bodyStr string
assert.NoError(t, json.Unmarshal(respBytes, &bodyStr))
Expand Down Expand Up @@ -742,6 +746,7 @@ func Test_sfxReceiver_EventAccessTokenPassthrough(t *testing.T) {
resp := w.Result()
respBytes, err := io.ReadAll(resp.Body)
assert.NoError(t, err)
defer resp.Body.Close()

var bodyStr string
assert.NoError(t, json.Unmarshal(respBytes, &bodyStr))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestSignalFxV2EventsToLogData(t *testing.T) {
}

func mapToEventProps(m map[string]interface{}) []*sfxpb.Property {
var out []*sfxpb.Property
out := make([]*sfxpb.Property, 0, len(m))
for k, v := range m {
var pval sfxpb.PropertyValue

Expand Down