From 3dd2282ed9548a28d23b314370eb3dd429bf0eba Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 26 Nov 2020 13:25:00 +0200 Subject: [PATCH] lib/promscrape: release http response non-200 status code --- lib/promscrape/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/promscrape/client.go b/lib/promscrape/client.go index b7a93ffbd6..c47f7a1bc3 100644 --- a/lib/promscrape/client.go +++ b/lib/promscrape/client.go @@ -215,13 +215,13 @@ func (c *client) ReadData(dst []byte) ([]byte, error) { } else if !swapResponseBodies { dst = append(dst, resp.Body()...) } + fasthttp.ReleaseResponse(resp) if statusCode != fasthttp.StatusOK { metrics.GetOrCreateCounter(fmt.Sprintf(`vm_promscrape_scrapes_total{status_code="%d"}`, statusCode)).Inc() return dst, fmt.Errorf("unexpected status code returned when scraping %q: %d; expecting %d; response body: %q", c.scrapeURL, statusCode, fasthttp.StatusOK, dst) } scrapesOK.Inc() - fasthttp.ReleaseResponse(resp) return dst, nil }