From 40bf7e49cc46a152edce3a48b0160a5131d4d346 Mon Sep 17 00:00:00 2001 From: Silvan Date: Tue, 2 May 2023 10:46:44 +0200 Subject: [PATCH] fix: correct tracing in access interceptor (#5766) --- internal/api/http/middleware/access_interceptor.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/api/http/middleware/access_interceptor.go b/internal/api/http/middleware/access_interceptor.go index 0de0e8c19b..4e95a83f6f 100644 --- a/internal/api/http/middleware/access_interceptor.go +++ b/internal/api/http/middleware/access_interceptor.go @@ -43,12 +43,10 @@ func (a *AccessInterceptor) Handle(next http.Handler) http.Handler { return next } return http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) { - ctx := request.Context() var err error - tracingCtx, span := tracing.NewServerInterceptorSpan(ctx) - defer func() { span.EndWithError(err) }() + tracingCtx, checkSpan := tracing.NewNamedSpan(ctx, "checkAccess") wrappedWriter := &statusRecorder{ResponseWriter: writer, status: 0} @@ -63,8 +61,13 @@ func (a *AccessInterceptor) Handle(next http.Handler) http.Handler { wrappedWriter.ignoreWrites = true } + checkSpan.End() + next.ServeHTTP(wrappedWriter, request) + tracingCtx, writeSpan := tracing.NewNamedSpan(tracingCtx, "writeAccess") + defer writeSpan.End() + requestURL := request.RequestURI unescapedURL, err := url.QueryUnescape(requestURL) if err != nil {