Browse Source

[ENHANCEMENT] HTTP API: Add url to errors logged while sending response

Give more clues when troubleshooting.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
pull/14209/head
Bryan Boreham 6 months ago
parent
commit
4ce26288e0
  1. 4
      web/api/v1/api.go

4
web/api/v1/api.go

@ -1761,7 +1761,7 @@ func (api *API) respond(w http.ResponseWriter, req *http.Request, data interface
b, err := codec.Encode(resp)
if err != nil {
level.Error(api.logger).Log("msg", "error marshaling response", "err", err)
level.Error(api.logger).Log("msg", "error marshaling response", "url", req.URL, "err", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@ -1769,7 +1769,7 @@ func (api *API) respond(w http.ResponseWriter, req *http.Request, data interface
w.Header().Set("Content-Type", codec.ContentType().String())
w.WriteHeader(http.StatusOK)
if n, err := w.Write(b); err != nil {
level.Error(api.logger).Log("msg", "error writing response", "bytesWritten", n, "err", err)
level.Error(api.logger).Log("msg", "error writing response", "url", req.URL, "bytesWritten", n, "err", err)
}
}

Loading…
Cancel
Save