diff --git a/middleware/metrics/metrics.go b/middleware/metrics/metrics.go index a269f6929..2f13b0b48 100644 --- a/middleware/metrics/metrics.go +++ b/middleware/metrics/metrics.go @@ -54,12 +54,13 @@ func Server(opts ...Option) middleware.Middleware { method = "POST" path = info.FullMethod } else if info, ok := http.FromServerContext(ctx); ok { - method = info.Request.Method - if route := mux.CurrentRoute(info.Request); route != nil { + req := info.Request.WithContext(ctx) + method = req.Method + if route := mux.CurrentRoute(req); route != nil { // /path/123 -> /path/{id} path, _ = route.GetPathTemplate() } else { - path = info.Request.RequestURI + path = req.RequestURI } } startTime := time.Now()