def serialize(self, obj, attrs, user): errors = [] error_set = set() for error in obj.data.get("errors", []): message = EventError.get_message(error) if message in error_set: continue error_set.add(message) error_result = { "type": error["type"], "message": message, "data": {k: v for k, v in error.items() if k != "type"}, } errors.append(error_result) # TODO(dcramer): move release serialization here d = { "id": str(obj.id), "groupID": obj.group.id, "eventID": str(obj.event_id), "size": obj.size, "entries": attrs["entries"], "message": obj.message, "user": attrs["user"], "context": obj.data.get("extra", {}), "packages": obj.data.get("modules", {}), "tags": dict(obj.get_tags(with_internal=False)), "platform": obj.platform, "dateCreated": obj.datetime, "timeSpent": obj.time_spent, "errors": errors, } return d
def serialize(self, obj, attrs, user): errors = [] error_set = set() for error in obj.data.get("errors", []): message = EventError.get_message(error) if message in error_set: continue error_set.add(message) error_result = {"type": error["type"], "message": message} errors.append(error_result) d = { "id": str(obj.id), "groupID": obj.group.id, "eventID": str(obj.event_id), "size": obj.size, "entries": attrs["entries"], "message": obj.message, "user": attrs["user"], "context": obj.data.get("extra", {}), "packages": obj.data.get("modules", {}), "tags": dict(obj.get_tags()), "platform": obj.platform, "dateCreated": obj.datetime, "timeSpent": obj.time_spent, "errors": errors, } return d
def serialize(self, obj, attrs, user): errors = [] error_set = set() for error in obj.data.get('errors', []): message = EventError.get_message(error) if message in error_set: continue error_set.add(message) error_result = { 'type': error['type'], 'message': message, 'data': {k: v for k, v in error.items() if k != 'type'}, } errors.append(error_result) # TODO(dcramer): move release serialization here d = { 'id': str(obj.id), 'groupID': obj.group.id, 'eventID': str(obj.event_id), 'size': obj.size, 'entries': attrs['entries'], 'message': obj.message, 'user': attrs['user'], 'context': obj.data.get('extra', {}), 'packages': obj.data.get('modules', {}), 'tags': dict(obj.get_tags()), 'platform': obj.platform, 'dateCreated': obj.datetime, 'timeSpent': obj.time_spent, 'errors': errors, } return d
def serialize(self, obj, attrs, user): errors = [] error_set = set() for error in obj.data.get('errors', []): message = EventError.get_message(error) if message in error_set: continue error_set.add(message) error_result = { 'type': error['type'], 'message': message, 'data': { k: v for k, v in six.iteritems(error) if k != 'type' }, } errors.append(error_result) tags = sorted([ { 'key': k.split('sentry:', 1)[-1], 'value': v } for k, v in obj.get_tags() ], key=lambda x: x['key']) received = obj.data.get('received') if received: # Sentry at one point attempted to record invalid types here. # Remove after June 2 2016 try: received = datetime.utcfromtimestamp(received).replace( tzinfo=timezone.utc, ) except TypeError: received = None # TODO(dcramer): move release serialization here d = { 'id': six.text_type(obj.id), 'groupID': six.text_type(obj.group_id), 'eventID': six.text_type(obj.event_id), 'size': obj.size, 'entries': attrs['entries'], # See GH-3248 'message': obj.get_legacy_message(), 'user': attrs['user'], 'contexts': attrs['contexts'], 'sdk': attrs['sdk'], # TODO(dcramer): move into contexts['extra'] 'context': obj.data.get('extra', {}), 'packages': obj.data.get('modules', {}), 'type': obj.get_event_type(), 'metadata': obj.get_event_metadata(), 'tags': tags, 'platform': obj.platform, 'dateCreated': obj.datetime, 'dateReceived': received, 'errors': errors, } return d
def summarize_issues(issues): rv = [] for issue in issues: extra_info = None msg_d = dict(issue['data']) msg_d['type'] = issue['type'] if 'image_path' in issue['data']: extra_info = issue['data']['image_path'].rsplit('/', 1)[-1] if 'image_arch' in issue['data']: extra_info = '%s (%s)' % (extra_info, issue['data']['image_arch'], ) rv.append({ 'message': EventError.get_message(msg_d), 'extra_info': extra_info, }) return rv
def serialize(self, obj, attrs, user): errors = [] error_set = set() for error in obj.data.get('errors', []): message = EventError.get_message(error) if message in error_set: continue error_set.add(message) error_result = { 'type': error['type'], 'message': message, 'data': { k: v for k, v in error.items() if k != 'type' }, } errors.append(error_result) tags = sorted([ { 'key': k.split('sentry:', 1)[-1], 'value': v } for k, v in obj.get_tags() ], key=lambda x: x['key']) # TODO(dcramer): move release serialization here d = { 'id': str(obj.id), 'groupID': obj.group.id, 'eventID': str(obj.event_id), 'size': obj.size, 'entries': attrs['entries'], 'message': obj.message, 'user': attrs['user'], 'context': obj.data.get('extra', {}), 'packages': obj.data.get('modules', {}), 'tags': tags, 'platform': obj.platform, 'dateCreated': obj.datetime, 'dateReceived': obj.data.get('received', obj.datetime), 'timeSpent': obj.time_spent, 'errors': errors, } return d
def summarize_issues(issues): rv = [] for issue in issues: extra_info = None msg_d = dict(issue['data']) msg_d['type'] = issue['type'] if 'image_path' in issue['data']: extra_info = issue['data']['image_path'].rsplit('/', 1)[-1] if 'image_arch' in issue['data']: extra_info = '%s (%s)' % ( extra_info, issue['data']['image_arch'], ) rv.append({ 'message': EventError.get_message(msg_d), 'extra_info': extra_info, }) return rv
def test_get_message(data, message): assert EventError.get_message(data) == message
def serialize(self, obj, attrs, user): errors = [] for error in obj.data.get('errors', []): message = EventError.get_message(error) error_result = { 'type': error['type'], 'message': message, 'data': {k: v for k, v in six.iteritems(error) if k != 'type'}, } errors.append(error_result) (message, message_meta) = self._get_message_with_meta(obj) (tags, tags_meta) = self._get_tags_with_meta(obj) (context, context_meta) = self._get_attr_with_meta(obj, 'extra', {}) (packages, packages_meta) = self._get_attr_with_meta(obj, 'modules', {}) received = obj.data.get('received') if received: # Sentry at one point attempted to record invalid types here. # Remove after June 2 2016 try: received = datetime.utcfromtimestamp(received).replace( tzinfo=timezone.utc, ) except TypeError: received = None from sentry.event_manager import ( get_hashes_from_fingerprint, md5_from_hash, ) # TODO(dcramer): move release serialization here d = { 'id': six.text_type(obj.id), 'groupID': six.text_type(obj.group_id), 'eventID': six.text_type(obj.event_id), 'size': obj.size, 'entries': attrs['entries'], 'dist': obj.dist, # See GH-3248 'message': message, 'user': attrs['user'], 'contexts': attrs['contexts'], 'sdk': attrs['sdk'], # TODO(dcramer): move into contexts['extra'] 'context': context, 'packages': packages, 'type': obj.get_event_type(), 'metadata': obj.get_event_metadata(), 'tags': tags, 'platform': obj.platform, 'dateCreated': obj.datetime, 'dateReceived': received, 'errors': errors, 'fingerprints': [ md5_from_hash(h) for h in get_hashes_from_fingerprint(obj, obj.data.get('fingerprint', ['{{ default }}'])) ], '_meta': { 'entries': attrs['_meta']['entries'], 'message': message_meta, 'user': attrs['_meta']['user'], 'contexts': attrs['_meta']['contexts'], 'sdk': attrs['_meta']['sdk'], 'context': context_meta, 'packages': packages_meta, 'tags': tags_meta, }, } return d
def test_event_error(error, type, message, data): assert EventError.get_message(error) == message assert EventError(error).type == type assert EventError(error).message == message assert EventError(error).data == data