Skip to content

Commit 2b59033

Browse files
committed
[chore] [exporter/splunk_hec] Remove dead code
`splunk.HandleHTTPCode` always returns an error for any codes other than 2xx. So the removed condition is always true and we always drain the response body
1 parent 95e35ee commit 2b59033

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

exporter/splunkhecexporter/hec_worker.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,9 @@ func (hec *defaultHecWorker) send(ctx context.Context, buf buffer, headers map[s
6767
return err
6868
}
6969

70-
// Do not drain the response when 429 or 502 status code is returned.
71-
// HTTP client will not reuse the same connection unless it is drained.
72-
// See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/18281 for more details.
73-
if resp.StatusCode != http.StatusTooManyRequests && resp.StatusCode != http.StatusBadGateway {
74-
if _, errCopy := io.Copy(io.Discard, resp.Body); errCopy != nil {
75-
return errCopy
76-
}
77-
}
78-
return nil
70+
// Drain the response body to avoid leaking connections.
71+
_, errCopy := io.Copy(io.Discard, resp.Body)
72+
return errCopy
7973
}
8074

8175
var _ hecWorker = &defaultHecWorker{}

0 commit comments

Comments
 (0)