mirror of
https://github.com/distribution/distribution.git
synced 2025-09-20 10:47:26 +00:00
health: use request context when logging
Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
@@ -282,7 +282,7 @@ func Handler(handler http.Handler) http.Handler {
|
|||||||
func statusResponse(w http.ResponseWriter, r *http.Request, status int, checks map[string]string) {
|
func statusResponse(w http.ResponseWriter, r *http.Request, status int, checks map[string]string) {
|
||||||
p, err := json.Marshal(checks)
|
p, err := json.Marshal(checks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dcontext.GetLogger(dcontext.Background()).Errorf("error serializing health status: %v", err)
|
dcontext.GetLogger(r.Context()).Errorf("error serializing health status: %v", err)
|
||||||
p, err = json.Marshal(struct {
|
p, err = json.Marshal(struct {
|
||||||
ServerError string `json:"server_error"`
|
ServerError string `json:"server_error"`
|
||||||
}{
|
}{
|
||||||
@@ -291,7 +291,7 @@ func statusResponse(w http.ResponseWriter, r *http.Request, status int, checks m
|
|||||||
status = http.StatusInternalServerError
|
status = http.StatusInternalServerError
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dcontext.GetLogger(dcontext.Background()).Errorf("error serializing health status failure message: %v", err)
|
dcontext.GetLogger(r.Context()).Errorf("error serializing health status failure message: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,7 +300,7 @@ func statusResponse(w http.ResponseWriter, r *http.Request, status int, checks m
|
|||||||
w.Header().Set("Content-Length", fmt.Sprint(len(p)))
|
w.Header().Set("Content-Length", fmt.Sprint(len(p)))
|
||||||
w.WriteHeader(status)
|
w.WriteHeader(status)
|
||||||
if _, err := w.Write(p); err != nil {
|
if _, err := w.Write(p); err != nil {
|
||||||
dcontext.GetLogger(dcontext.Background()).Errorf("error writing health status response body: %v", err)
|
dcontext.GetLogger(r.Context()).Errorf("error writing health status response body: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user