def send(self, **kwargs): "Sends the message to the server." if settings.REMOTE_URL: message = base64.b64encode(json.dumps(kwargs).encode("zlib")) for url in settings.REMOTE_URL: timestamp = time.time() signature = get_signature(message, timestamp) headers = { "Authorization": get_auth_header( signature, timestamp, "%s/%s" % (self.__class__.__name__, sentry.VERSION) ), "Content-Type": "application/octet-stream", } try: return 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))
def _postWithSignature(self, data): ts = time.time() message = base64.b64encode(json.dumps(transform(data))) sig = get_signature(message, ts) resp = self.client.post(reverse('sentry-store'), message, content_type='application/octet-stream', HTTP_AUTHORIZATION=get_auth_header(sig, ts, '_postWithSignature'), ) return resp
def send(self, **kwargs): "Sends the message to the server." if settings.REMOTE_URL: for url in settings.REMOTE_URL: message = base64.b64encode( simplejson.dumps(kwargs).encode('zlib')) timestamp = time.time() signature = get_signature(message, timestamp) headers = { 'Authorization': get_auth_header( signature, timestamp, '%s/%s' % (self.__class__.__name__, sentry.VERSION)), 'Content-Type': 'application/octet-stream', } try: return 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=sys.exc_info(), 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=sys.exc_info(), extra={'data': { 'remote_url': url }}) logger.log( kwargs.pop('level', None) or logging.ERROR, kwargs.pop('message', None))
def send(self, **kwargs): "Sends the message to the server." if settings.REMOTE_URL: for url in settings.REMOTE_URL: message = base64.b64encode(json.dumps(kwargs).encode('zlib')) timestamp = time.time() signature = get_signature(message, timestamp) headers={ 'Authorization': get_auth_header(signature, timestamp, '%s/%s' % (self.__class__.__name__, sentry.VERSION)), 'Content-Type': 'application/octet-stream', } try: return 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=sys.exc_info(), 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=sys.exc_info(), extra={'data':{'remote_url': url}}) logger.log(kwargs.pop('level', None) or logging.ERROR, kwargs.pop('message', None))