diff --git a/health/health.go b/health/health.go index 57a714b6..67873f59 100644 --- a/health/health.go +++ b/health/health.go @@ -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) { p, err := json.Marshal(checks) 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 { ServerError string `json:"server_error"` }{ @@ -291,7 +291,7 @@ func statusResponse(w http.ResponseWriter, r *http.Request, status int, checks m status = http.StatusInternalServerError 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 } } @@ -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.WriteHeader(status) 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) } }