Include request_id in HTTP request logs (#12880)

This commit is contained in:
Ben Schumacher
2019-10-25 20:02:18 +02:00
committed by GitHub
parent f58e2ffd0f
commit 37e0424977

View File

@@ -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")