Пример #1
0
    def send(self, **data):
        """
        Sends the message to the server.

        If ``servers`` was passed into the constructor, this will serialize the data and pipe it to
        each server using ``send_remote()``. Otherwise, this will communicate with ``sentry.models.GroupedMessage``
        directly.
        """
        message = base64.b64encode(json.dumps(data).encode('zlib'))

        for url in self.servers:
            timestamp = time.time()
            signature = get_signature(message, timestamp, self.secret_key or self.key)
            headers = {
                'X-Sentry-Auth': get_auth_header(signature, timestamp, 'raven/%s' % (raven.VERSION,), self.public_key),
                'Content-Type': 'application/octet-stream',
            }

            try:
                self.send_remote(url=url, data=message, headers=headers)
            except urllib2.HTTPError, e:
                body = e.read()
                self.logger.error('Unable to reach Sentry log server: %s (url: %%s, body: %%s)' % (e,), url, body,
                             exc_info=True, extra={'data': {'body': body, 'remote_url': url}})
                self.logger.log(data.pop('level', None) or logging.ERROR, data.pop('message', None))
            except urllib2.URLError, e:
                self.logger.error('Unable to reach Sentry log server: %s (url: %%s)' % (e,), url,
                             exc_info=True, extra={'data': {'remote_url': url}})
                self.logger.log(data.pop('level', None) or logging.ERROR, data.pop('message', None))
Пример #2
0
    def send(self, **data):
        """
        Sends the message to the server.

        If ``servers`` was passed into the constructor, this will serialize the data and pipe it to
        each server using ``send_remote()``. Otherwise, this will communicate with ``sentry.models.GroupedMessage``
        directly.
        """
        message = base64.b64encode(json.dumps(data).encode('zlib'))

        for url in self.servers:
            timestamp = time.time()
            signature = get_signature(message, timestamp, self.secret_key or self.key)
            headers = {
                'X-Sentry-Auth': get_auth_header(signature, timestamp, 'raven/%s' % (raven.VERSION,), self.public_key),
                'Content-Type': 'application/octet-stream',
            }

            try:
                self.send_remote(url=url, data=message, headers=headers)
            except urllib2.HTTPError, e:
                body = e.read()
                self.logger.error('Unable to reach Sentry log server: %s (url: %%s, body: %%s)' % (e,), url, body,
                             exc_info=True, extra={'data': {'body': body, 'remote_url': url}})
                self.logger.log(data.pop('level', None) or logging.ERROR, data.pop('message', None))
            except urllib2.URLError, e:
                self.logger.error('Unable to reach Sentry log server: %s (url: %%s)' % (e,), url,
                             exc_info=True, extra={'data': {'remote_url': url}})
                self.logger.log(data.pop('level', None) or logging.ERROR, data.pop('message', None))
Пример #3
0
    def send(self, **data):
        """
        Sends the message to the server.

        If ``servers`` was passed into the constructor, this will serialize the data and pipe it to
        each server using ``send_remote()``. Otherwise, this will communicate with ``sentry.models.GroupedMessage``
        directly.
        """
        message = base64.b64encode(json.dumps(data).encode('zlib'))

        for url in self.servers:
            timestamp = time.time()
            signature = get_signature(message, timestamp, self.secret_key or self.key)
            headers = {
                'X-Sentry-Auth': get_auth_header(signature, timestamp, 'raven/%s' % (raven.VERSION,), self.public_key),
                'Content-Type': 'application/octet-stream',
            }

            self.send_remote(url=url, data=message, headers=headers)
Пример #4
0
    def send_encoded(self, message):
        """
        Given an already serialized message, signs the message and passes the payload
        off to ``send_remote`` for each server specified in the servers configuration.
        """
        for url in self.servers:
            timestamp = time.time()
            signature = get_signature(message, timestamp, self.secret_key or self.key)
            headers = {
                'X-Sentry-Auth': get_auth_header(
                    protocol=self.protocol_version,
                    signature=signature,
                    timestamp=timestamp,
                    client='raven-python/%s' % (raven.VERSION,),
                    api_key=self.public_key
                ),
                'Content-Type': 'application/octet-stream',
            }

            self.send_remote(url=url, data=message, headers=headers)
Пример #5
0
    def send_encoded(self, message):
        """
        Given an already serialized message, signs the message and passes the payload
        off to ``send_remote`` for each server specified in the servers configuration.
        """
        for url in self.servers:
            timestamp = time.time()
            signature = get_signature(message, timestamp, self.secret_key
                                      or self.key)
            headers = {
                'X-Sentry-Auth':
                get_auth_header(protocol=self.protocol_version,
                                signature=signature,
                                timestamp=timestamp,
                                client='raven-python/%s' % (raven.VERSION, ),
                                api_key=self.public_key),
                'Content-Type':
                'application/octet-stream',
            }

            self.send_remote(url=url, data=message, headers=headers)
Пример #6
0
    def send(self, **kwargs):
        """
        Sends the message to the server.

        If ``servers`` was passed into the constructor, this will serialize the data and pipe it to
        each server using ``send_remote()``. Otherwise, this will communicate with ``sentry.models.GroupedMessage``
        directly.
        """
        message = base64.b64encode(json.dumps(kwargs).encode("zlib"))
        for url in self.servers:
            timestamp = time.time()
            signature = get_signature(self.key, message, timestamp)
            headers = {
                "Authorization": get_auth_header(
                    signature, timestamp, "%s/%s" % (self.__class__.__name__, raven.VERSION)
                ),
                "Content-Type": "application/octet-stream",
            }

            try:
                self.send_remote(url=url, data=message, headers=headers)
            except urllib2.HTTPError, e:
                body = e.read()
                logger.error(
                    "Unable to reach Sentry log server: %s (url: %%s, body: %%s)" % (e,),
                    url,
                    body,
                    exc_info=True,
                    extra={"data": {"body": body, "remote_url": url}},
                )
                logger.log(kwargs.pop("level", None) or logging.ERROR, kwargs.pop("message", None))
            except urllib2.URLError, e:
                logger.error(
                    "Unable to reach Sentry log server: %s (url: %%s)" % (e,),
                    url,
                    exc_info=True,
                    extra={"data": {"remote_url": url}},
                )
                logger.log(kwargs.pop("level", None) or logging.ERROR, kwargs.pop("message", None))