Prometheus: Fix resource call panic (#50216) (#50221)

(cherry picked from commit 4aa5e7e69e)

Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2022-06-06 03:52:58 +02:00
committed by GitHub
co-authored by Todd Treece
parent 4f284f167e
commit bb801de9ed
+5 -1
View File
@@ -58,7 +58,11 @@ func (r *Resource) fetch(ctx context.Context, client *client.Client, req *backen
resp, err := client.QueryResource(ctx, req.Method, u.Path, u.Query())
if err != nil {
return resp.StatusCode, nil, err
statusCode := 500
if resp != nil {
statusCode = resp.StatusCode
}
return statusCode, nil, err
}
defer resp.Body.Close() //nolint (we don't care about the error being returned by resp.Body.Close())