Skip to content
Merged
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
12 changes: 3 additions & 9 deletions exporter/splunkhecexporter/hec_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,9 @@ func (hec *defaultHecWorker) send(ctx context.Context, buf buffer, headers map[s
return err
}

// Do not drain the response when 429 or 502 status code is returned.
// HTTP client will not reuse the same connection unless it is drained.
// See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/18281 for more details.
if resp.StatusCode != http.StatusTooManyRequests && resp.StatusCode != http.StatusBadGateway {
if _, errCopy := io.Copy(io.Discard, resp.Body); errCopy != nil {
return errCopy
}
}
return nil
// Drain the response body to avoid leaking connections.
_, errCopy := io.Copy(io.Discard, resp.Body)
return errCopy // TODO: Do not return error here. Draining errors is not a failure in data sending.
}

var _ hecWorker = &defaultHecWorker{}
Loading