Skip to content

Commit

Permalink
datadogexporter: read response body on pushSketches
Browse files Browse the repository at this point in the history
  • Loading branch information
spudlymurf authored Dec 11, 2024
1 parent 421d710 commit b265c3b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions exporter/datadogexporter/metrics_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ func (exp *metricsExporter) pushSketches(ctx context.Context, sl sketches.Sketch
}
defer resp.Body.Close()

// We must read the full response body from the http request to ensure that connections can be
// properly re-used. https://pkg.go.dev/net/http#Client.Do
_, err = io.Copy(io.Discard, resp.Body)

Check failure on line 159 in exporter/datadogexporter/metrics_exporter.go

View workflow job for this annotation

GitHub Actions / govulncheck (exporter-1)

undefined: io

Check failure on line 159 in exporter/datadogexporter/metrics_exporter.go

View workflow job for this annotation

GitHub Actions / govulncheck (exporter-1)

undefined: io

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

0 comments on commit b265c3b

Please sign in to comment.