From ae9a8fb5304fca0a1dc0441cb991227320033bca Mon Sep 17 00:00:00 2001 From: Ercan Ucan Date: Tue, 23 Feb 2021 16:35:37 +0100 Subject: fix: use correlationID middleware As discussed within https://gitlab.com/gitlab-org/gitlab-pages/-/issues/510 this MR adds the usage of labkit's correlationID middleware. It uses a similar approach to the implemantion in gitlab-workhorse. Fixes https://gitlab.com/gitlab-org/gitlab-pages/-/issues/510 :tools: with :heart: at Siemens Changelog: fixed --- app.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app.go') diff --git a/app.go b/app.go index 0a6f0cd4..40bfd153 100644 --- a/app.go +++ b/app.go @@ -15,6 +15,7 @@ import ( log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/go-mimedb" + "gitlab.com/gitlab-org/labkit/correlation" "gitlab.com/gitlab-org/labkit/errortracking" labmetrics "gitlab.com/gitlab-org/labkit/metrics" "gitlab.com/gitlab-org/labkit/monitoring" @@ -339,6 +340,13 @@ func (a *theApp) buildHandlerPipeline() (http.Handler, error) { // Custom response headers handler = a.customHeadersMiddleware(handler) + // Correlation ID injection middleware + var correlationOpts []correlation.InboundHandlerOption + if a.appConfig.PropagateCorrelationID { + correlationOpts = append(correlationOpts, correlation.WithPropagation()) + } + handler = correlation.InjectCorrelationID(handler, correlationOpts...) + // This MUST be the last handler! // This handler blocks unknown HTTP methods, // being the last means it will be evaluated first -- cgit v1.2.3