From 37e042497717fab807fc8742c4ae771af9f5c255 Mon Sep 17 00:00:00 2001 From: Ben Schumacher Date: Fri, 25 Oct 2019 20:02:18 +0200 Subject: [PATCH] Include request_id in HTTP request logs (#12880) --- web/handlers.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/handlers.go b/web/handlers.go index a666501f6d..ea2885ba13 100644 --- a/web/handlers.go +++ b/web/handlers.go @@ -72,14 +72,16 @@ type Handler struct { func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { now := time.Now() - mlog.Debug("request:", mlog.String("method", r.Method), mlog.String("url", r.URL.Path)) + + requestID := model.NewId() + mlog.Debug("Received HTTP request", mlog.String("method", r.Method), mlog.String("url", r.URL.Path), mlog.String("request_id", requestID)) c := &Context{} c.App = app.New( h.GetGlobalAppOptions()..., ) c.App.T, _ = utils.GetTranslationsAndLocale(w, r) - c.App.RequestId = model.NewId() + c.App.RequestId = requestID c.App.IpAddress = utils.GetIpAddress(r, c.App.Config().ServiceSettings.TrustedProxyIPHeader) c.App.UserAgent = r.UserAgent() c.App.AcceptLanguage = r.Header.Get("Accept-Language")