X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/201d0473e44d444fc93223a973688233ac289353..530db6b1a9e164213422da56a38f2551a559747d:/sdk/go/httpserver/logger.go diff --git a/sdk/go/httpserver/logger.go b/sdk/go/httpserver/logger.go index 30f5e2612b..8886f9517d 100644 --- a/sdk/go/httpserver/logger.go +++ b/sdk/go/httpserver/logger.go @@ -68,10 +68,16 @@ func logRequest(w *responseTimer, req *http.Request, lgr *logrus.Entry) { func logResponse(w *responseTimer, req *http.Request, lgr *logrus.Entry) { if tStart, ok := req.Context().Value(&requestTimeContextKey).(time.Time); ok { tDone := time.Now() + writeTime := w.writeTime + if !w.wrote { + // Empty response body. Header was sent when + // handler exited. + writeTime = tDone + } lgr = lgr.WithFields(logrus.Fields{ "timeTotal": stats.Duration(tDone.Sub(tStart)), - "timeToStatus": stats.Duration(w.writeTime.Sub(tStart)), - "timeWriteBody": stats.Duration(tDone.Sub(w.writeTime)), + "timeToStatus": stats.Duration(writeTime.Sub(tStart)), + "timeWriteBody": stats.Duration(tDone.Sub(writeTime)), }) } respCode := w.WroteStatus()