return await call_next(request) route = request.scope.get("route") template = getattr(route, "path_format", getattr(route, "path", path)) tags = { "endpoint": f"{request.method}:{template}", "method": request.method, } with pyroscope.tag_wrapper(tags): response = await call_next(request) return response