Commit 8b157fd2 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'include-route-field-in-logs' into 'master'

Include route identifier in access logs

See merge request gitlab-org/gitlab-workhorse!624
parents f86fc568 822b8b15
---
title: Include route regex identifier in structured logs
merge_request: 624
author:
type: other
This diff is collapsed.
...@@ -14,7 +14,6 @@ import ( ...@@ -14,7 +14,6 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/labkit/correlation" "gitlab.com/gitlab-org/labkit/correlation"
"gitlab.com/gitlab-org/labkit/log"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/config" "gitlab.com/gitlab-org/gitlab-workhorse/internal/config"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper" "gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
...@@ -36,11 +35,13 @@ type upstream struct { ...@@ -36,11 +35,13 @@ type upstream struct {
Routes []routeEntry Routes []routeEntry
RoundTripper http.RoundTripper RoundTripper http.RoundTripper
CableRoundTripper http.RoundTripper CableRoundTripper http.RoundTripper
accessLogger *logrus.Logger
} }
func NewUpstream(cfg config.Config, accessLogger *logrus.Logger) http.Handler { func NewUpstream(cfg config.Config, accessLogger *logrus.Logger) http.Handler {
up := upstream{ up := upstream{
Config: cfg, Config: cfg,
accessLogger: accessLogger,
} }
if up.Backend == nil { if up.Backend == nil {
up.Backend = DefaultBackend up.Backend = DefaultBackend
...@@ -61,8 +62,7 @@ func NewUpstream(cfg config.Config, accessLogger *logrus.Logger) http.Handler { ...@@ -61,8 +62,7 @@ func NewUpstream(cfg config.Config, accessLogger *logrus.Logger) http.Handler {
correlationOpts = append(correlationOpts, correlation.WithPropagation()) correlationOpts = append(correlationOpts, correlation.WithPropagation())
} }
handler := log.AccessLogger(&up, log.WithAccessLogger(accessLogger)) handler := correlation.InjectCorrelationID(&up, correlationOpts...)
handler = correlation.InjectCorrelationID(handler, correlationOpts...)
return handler return handler
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment