예제 #1
0
    def scout_tween(request):
        try:
            tr = TrackedRequest.instance()
            span = tr.start_span(operation="Controller/Pyramid")

            if ignore_path(request.path):
                tr.tag("ignore_transaction", True)

            # Capture what we can from the request, but never fail
            try:
                Context.add("path", request.path)
                Context.add("user_ip", request.remote_addr)
            except Exception:
                pass

            try:
                response = handler(request)
            except Exception:
                tr.tag("error", "true")
                raise

            # This happens further down the call chain. So time it starting
            # above, but only name it if it gets to here.
            if request.matched_route is not None:
                tr.mark_real_request()
                span.operation = "Controller/" + request.matched_route.name

        finally:
            tr.stop_span()

        return response
예제 #2
0
    def scout_tween(request):
        try:
            tr = TrackedRequest.instance()
            span = tr.start_span(operation='Controller/Pyramid')

            # Capture what we can from the request, but never fail
            try:
                Context.add('path', request.path)
                Context.add('user_ip', request.remote_addr)
            except:
                pass

            try:
                response = handler(request)
            except:
                tr.tag('error', 'true')
                raise

            # This happens further down the call chain. So time it starting
            # above, but only name it if it gets to here.
            if request.matched_route is not None:
                tr.mark_real_request()
                span.operation = 'Controller/' + request.matched_route.name

        finally:
            tr.stop_span()

        return response
예제 #3
0
        def wrapper(*args, **kwargs):
            try:
                tr = TrackedRequest.instance()
                tr.mark_real_request()
                path = 'Unknown'

                if request.route.name is not None:
                    path = request.route.name
                else:
                    path = request.route.rule

                if path == '/':
                    path = '/home'

                if not path.startswith('/'):
                    path = '/{}'.format(path)

                span = tr.start_span(operation='Controller{}'.format(path))

                try:
                    Context.add('path', path)
                    Context.add('user_ip', request.remote_addr)
                except:
                    pass

                try:
                    response = callback(*args, **kwargs)
                except:
                    tr.tag('error', 'true')
                    raise

            finally:
                tr.stop_span()

            return response
예제 #4
0
        def wrapper(*args, **kwargs):
            try:
                tr = TrackedRequest.instance()
                tr.mark_real_request()
                path = "Unknown"

                if request.route.name is not None:
                    path = request.route.name
                else:
                    path = request.route.rule

                if path == "/":
                    path = "/home"

                if not path.startswith("/"):
                    path = "/{}".format(path)

                tr.start_span(operation="Controller{}".format(path))

                if ignore_path(path):
                    tr.tag("ignore_transaction", True)

                try:
                    Context.add("path", path)
                    Context.add("user_ip", request.remote_addr)
                except Exception:
                    pass

                try:
                    response = callback(*args, **kwargs)
                except Exception:
                    tr.tag("error", "true")
                    raise

            finally:
                tr.stop_span()

            return response
예제 #5
0
    def process_view(self, request, view_func, view_func_args,
                     view_func_kwargs):
        tr = TrackedRequest.instance()

        if ignore_path(request.path):
            tr.tag("ignore_transaction", True)

        view_name = request.resolver_match._func_path
        operation = "Controller/" + view_name

        span = tr.start_span(operation=operation)
        tr.mark_real_request()

        # Save the span into the request, so we can check
        # if we're matched up when stopping
        request.scout_view_span = span

        try:
            if getattr(request, "user", None) is not None:
                Context.add("username", request.user.get_username())
        except Exception:
            pass

        return None
예제 #6
0
 def process_view(self, request, view_func, view_args, view_kwargs):
     """
     Capture details about the view_func that is about to execute
     """
     try:
         view_name = request.resolver_match._func_path
         span = TrackedRequest.instance().current_span()
         if span is not None:
             span.operation = 'Controller/' + view_name
             Context.add('path', request.path)
             Context.add('user_ip', RemoteIp.lookup_from_headers(request.META))
             if request.user is not None:
                 Context.add('username', request.user.get_username())
     except:
         pass
예제 #7
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        """
        Capture details about the view_func that is about to execute
        """
        try:
            if ignore_path(request.path):
                TrackedRequest.instance().tag("ignore_transaction", True)

            view_name = request.resolver_match._func_path
            span = TrackedRequest.instance().current_span()
            if span is not None:
                span.operation = "Controller/" + view_name
                Context.add("path", request.path)
                Context.add("user_ip",
                            RemoteIp.lookup_from_headers(request.META))
                if getattr(request, "user", None) is not None:
                    Context.add("username", request.user.get_username())
        except Exception:
            pass