Example #1
0
    def process_view(self, request: Request, view_func, view_args,
                     view_kwargs) -> Response:
        if not hasattr(request, "_metric_tags"):
            request._metric_tags = {}

        if request.method not in self.allowed_methods:
            return

        view = view_func
        if not inspect.isfunction(view_func):
            view = view.__class__

        try:
            path = f"{view.__module__}.{view.__name__}"
        except AttributeError:
            return

        if not path.startswith(self.allowed_paths):
            return

        request._view_path = path
        request._start_time = time.time()