Esempio n. 1
0
    def process_request(self, request):
        request.environ["HTTP_X_SERVICE_NAME"] = self.service_name or request.host
        payload = {"request": self.environ_to_dict(request.environ)}

        api.notify(
            context.get_admin_context(),
            api.publisher_id(os.path.basename(sys.argv[0])),
            "http.request",
            api.INFO,
            payload,
        )
Esempio n. 2
0
    def process_response(self, request, response, exception=None, traceback=None):
        payload = {"request": self.environ_to_dict(request.environ)}

        if response:
            payload["response"] = {"status": response.status, "headers": response.headers}

        if exception:
            payload["exception"] = {"value": repr(exception), "traceback": tb.format_tb(traceback)}

        api.notify(
            context.get_admin_context(),
            api.publisher_id(os.path.basename(sys.argv[0])),
            "http.response",
            api.INFO,
            payload,
        )