Skip to content

Commit c65bf5e

Browse files
author
Damian Murphy
committed
Handle error on body read.
1 parent 7e72de3 commit c65bf5e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

exporter/datadogexporter/metrics_exporter.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ func (exp *metricsExporter) pushSketches(ctx context.Context, sl sketches.Sketch
158158
// We must read the full response body from the http request to ensure that connections can be
159159
// properly re-used. https://pkg.go.dev/net/http#Client.Do
160160
_, err = io.Copy(io.Discard, resp.Body)
161+
if err != nil {
162+
return clientutil.WrapError(fmt.Errorf("failed to read response body from sketches HTTP request: %w", err), resp)
163+
}
161164

162165
if resp.StatusCode >= 400 {
163166
return clientutil.WrapError(fmt.Errorf("error when sending payload to %s: %s", sketches.SketchSeriesEndpoint, resp.Status), resp)

0 commit comments

Comments
 (0)