def processing_crash_dump(self, crash_pk): try: crash = Crash.objects.get(pk=crash_pk) url = furl(crash.upload_file_minidump.url) path = url.pathstr crash_dump_path = os.path.join(S3_MOUNT_PATH, *path.split('/')) stacktrace, errors = get_stacktrace(crash_dump_path) crash.stacktrace = stacktrace crash.stacktrace_json = parse_stacktrace(stacktrace) crash.signature = get_signature(crash.stacktrace_json) crash.save() send_stacktrace_sentry(crash) except FileNotFoundError as exc: logger.error( 'Failed processing_crash_dump', exc_info=True, extra=dict(crash_pk=crash_pk, crash_dump_path=crash_dump_path)) raise self.retry( exc=exc, countdown=2**processing_crash_dump.request.retries) except CommandError as exc: logger.error( 'Failed processing_crash_dump', exc_info=True, extra=dict(crash_pk=crash_pk, crash_dump_path=crash_dump_path)) raise exc
def processing_crash_dump(self, crash_pk): try: crash = Crash.objects.get(pk=crash_pk) url = furl(crash.upload_file_minidump.url) path = url.pathstr crash_dump_path = os.path.join(S3_MOUNT_PATH, *path.split('/')) stacktrace, errors = get_stacktrace(crash_dump_path) crash.stacktrace = stacktrace crash.stacktrace_json = parse_stacktrace(stacktrace) crash.signature = get_signature(crash.stacktrace_json) crash.os = get_os(crash.stacktrace_json) crash.build_number = crash.meta.get('ver') crash.save() send_stacktrace_sentry(crash) except FileNotFoundError as exc: logger.error('Failed processing_crash_dump', exc_info=True, extra=dict(crash_pk=crash_pk, crash_dump_path=crash_dump_path)) raise self.retry(exc=exc, countdown=2 ** processing_crash_dump.request.retries) except CommandError as exc: logger.error('Failed processing_crash_dump', exc_info=True, extra=dict(crash_pk=crash_pk, crash_dump_path=crash_dump_path)) raise exc
def test_parse_stacktrace(self): stacktrace_dict = parse_stacktrace(stacktrace) self.assertDictEqual(stacktrace_dict['crashing_thread']['frames'][0], {'abs_path': r'c:\work\breakpadtestapp\breakpadtestapp\breakpadtestapp.cpp', 'frame': 0, 'function': 'crashedFunc()', 'lineno': 34, 'filename': 'BreakpadTestApp.exe', 'short_signature': 'crashedFunc', 'signature': 'crashedFunc()'})
def processing_crash_dump(self, crash_pk): try: crash = Crash.objects.get(pk=crash_pk) # assemble crash_dump_path url = furl(crash.upload_file_minidump.url) path = url.pathstr crash_dump_path = os.path.join(S3_MOUNT_PATH, *path.split('/')) # Set various values in the crash object. stacktrace = get_stacktrace(crash_dump_path) crash.stacktrace = stacktrace crash.stacktrace_json = parse_stacktrace(stacktrace) crash.signature = get_signature(crash.stacktrace_json) _os = get_os(crash.stacktrace_json) meta = crash.meta or {} build_number = meta.get('ver', '') channel = meta.get('channel', '') or get_channel(build_number, _os) crash.os = _os crash.build_number = build_number crash.channel = channel crash.save() # Send the crash to the configured logger. send_stacktrace(crash) except FileNotFoundError as exc: logger.error('Failed processing_crash_dump', exc_info=True, extra=dict(crash_pk=crash_pk, crash_dump_path=crash_dump_path)) raise self.retry(exc=exc, countdown=2**processing_crash_dump.request.retries) except CommandError as exc: logger.error('Failed processing_crash_dump', exc_info=True, extra=dict(crash_pk=crash_pk, crash_dump_path=crash_dump_path)) raise exc
def processing_crash_dump(self, crash_pk): try: crash = Crash.objects.get(pk=crash_pk) # assemble crash_dump_path url = furl(crash.upload_file_minidump.url) path = url.pathstr crash_dump_path = os.path.join(S3_MOUNT_PATH, *path.split('/')) # Set various values in the crash object. stacktrace = get_stacktrace(crash_dump_path) crash.stacktrace = stacktrace crash.stacktrace_json = parse_stacktrace(stacktrace) crash.signature = get_signature(crash.stacktrace_json) _os = get_os(crash.stacktrace_json) meta = crash.meta or {} build_number = meta.get('ver', '') channel = meta.get('channel', '') or get_channel(build_number, _os) crash.os = _os crash.build_number = build_number crash.channel = channel crash.save() # Send the crash to the configured logger. send_stacktrace(crash) except FileNotFoundError as exc: logger.error('Failed processing_crash_dump', exc_info=True, extra=dict(crash_pk=crash_pk, crash_dump_path=crash_dump_path)) raise self.retry(exc=exc, countdown=2 ** processing_crash_dump.request.retries) except CommandError as exc: logger.error('Failed processing_crash_dump', exc_info=True, extra=dict(crash_pk=crash_pk, crash_dump_path=crash_dump_path)) raise exc
def test_send_stacktrace_sentry(self, mock_client): meta = dict( lang='en', version='1.0.0.1', ) crash = Crash( pk=123, upload_file_minidump=SimpleUploadedFile('./dump.dat', False), stacktrace=stacktrace, stacktrace_json=parse_stacktrace(stacktrace), appid='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', userid='{2882CF9B-D9C2-4edb-9AAF-8ED5FCF366F7}', meta=meta, signature='signature', ) send_stacktrace_sentry(crash) extra = { 'crash_admin_panel_url': 'http://{}{}'.format( 'example.com', '/admin/crash/crash/%s/' % crash.pk), 'crashdump_url': crash.upload_file_minidump.url, 'lang': 'en', 'version': '1.0.0.1'} data = { 'sentry.interfaces.User': { 'id': '{2882CF9B-D9C2-4edb-9AAF-8ED5FCF366F7}' }, 'sentry.interfaces.Exception': { 'values': [ {'stacktrace': { 'frames': [ {'function': 'crashedFunc()', 'abs_path': r'c:\work\breakpadtestapp\breakpadtestapp\breakpadtestapp.cpp', 'short_signature': 'crashedFunc', 'frame': 0, 'filename': 'BreakpadTestApp.exe', 'lineno': 34, 'signature': 'crashedFunc()'}, {'function': 'deeperFunc()', 'abs_path': r'c:\work\breakpadtestapp\breakpadtestapp\breakpadtestapp.cpp', 'short_signature': 'deeperFunc', 'frame': 1, 'filename': 'BreakpadTestApp.exe', 'lineno': 39, 'signature': 'deeperFunc()'}, {'function': 'deepFunc()', 'abs_path': r'c:\work\breakpadtestapp\breakpadtestapp\breakpadtestapp.cpp', 'short_signature': 'deepFunc', 'frame': 2, 'filename': 'BreakpadTestApp.exe', 'lineno': 44, 'signature': 'deepFunc()'}, {'function': 'anotherFunc()', 'abs_path': r'c:\work\breakpadtestapp\breakpadtestapp\breakpadtestapp.cpp', 'short_signature': 'anotherFunc', 'frame': 3, 'filename': 'BreakpadTestApp.exe', 'lineno': 49, 'signature': 'anotherFunc()'}, {'function': 'someFunc()', 'abs_path': r'c:\work\breakpadtestapp\breakpadtestapp\breakpadtestapp.cpp', 'short_signature': 'someFunc', 'frame': 4, 'filename': 'BreakpadTestApp.exe', 'lineno': 54, 'signature': 'someFunc()'}, { 'function': 'func()', 'abs_path': r'c:\work\breakpadtestapp\breakpadtestapp\breakpadtestapp.cpp', 'short_signature': 'func', 'frame': 5, 'filename': 'BreakpadTestApp.exe', 'lineno': 59, 'signature': 'func()'}, {'function': 'wmain', 'abs_path': r'c:\work\breakpadtestapp\breakpadtestapp\breakpadtestapp.cpp', 'short_signature': 'wmain', 'frame': 6, 'filename': 'BreakpadTestApp.exe', 'lineno': 84, 'signature': 'wmain'}, { 'function': '__tmainCRTStartup', 'abs_path': r'f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c', 'short_signature': '__tmainCRTStartup', 'frame': 7, 'filename': 'BreakpadTestApp.exe', 'lineno': 579, 'signature': '__tmainCRTStartup'}, {'frame': 8, 'module_offset': '0x13676', 'signature': 'kernel32.dll@0x13676', 'short_signature': 'kernel32.dll@0x13676', 'filename': 'kernel32.dll'}, {'frame': 9, 'module_offset': '0x39d41', 'signature': 'ntdll.dll@0x39d41', 'short_signature': 'ntdll.dll@0x39d41', 'filename': 'ntdll.dll'}], 'total_frames': 11, 'threads_index': 0}, 'type': 'EXCEPTION_ACCESS_VIOLATION_WRITE', 'value': '0x0'} ] } } tags = { 'cpu_arch': 'x86', 'cpu_count': 4, 'appid': '{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', 'cpu_info': 'GenuineIntel family 6 model 42 stepping 7', 'os': 'Windows NT', 'os_ver': '6.1.7600' } mock_client.capture.assert_called_once_with( 'raven.events.Message', message='signature', extra=extra, data=data, tags=tags, )
def test_get_signature(self): self.assertEqual(get_signature(parse_stacktrace(stacktrace)), 'crashedFunc()')