def _normalize_in_app(stacktrace, platform=None, sdk_info=None): """ Ensures consistent values of in_app across a stacktrace. """ # Native frames have special rules regarding in_app. Apply them before other # normalization, just like grouping enhancers. # TODO(ja): Clean up those rules and put them in enhancers instead for frame in stacktrace: if frame.get('in_app') is not None: continue family = get_grouping_family_for_platform(frame.get('platform') or platform) if family == 'native': frame_package = frame.get('package') frame['in_app'] = bool(frame_package) and \ not is_known_third_party(frame_package, sdk_info=sdk_info) has_system_frames = _has_system_frames(stacktrace) for frame in stacktrace: # If all frames are in_app, flip all of them. This is expected by the UI if not has_system_frames: frame['in_app'] = False # Default to false in all cases where processors or grouping enhancers # have not yet set in_app. elif frame.get('in_app') is None: frame['in_app'] = False
def _push_frame(frame): self._frames.append({ 'function': trim_function_name(frame.get('function'), '<unknown>'), 'path': frame.get('abs_path') or frame.get('filename'), 'module': frame.get('module'), 'family': get_grouping_family_for_platform( frame.get('platform') or self.event.get('platform')), })
def get_exceptions(self): if self._exceptions is None: self._exceptions = [] for exc in get_path(self.event, 'exception', 'values', filter=True) or (): self._exceptions.append({ 'type': exc.get('type'), 'value': exc.get('value'), 'family': get_grouping_family_for_platform( self.event.get('platform')), }) return self._exceptions
def get_messages(self): if self._messages is None: self._messages = [] message = get_path(self.event, 'logentry', 'formatted', filter=True) if message: self._messages.append({ 'message': message, 'family': get_grouping_family_for_platform( self.event.get('platform')), }) return self._messages
def matches_frame(self, frame_data, platform): # Path matches are always case insensitive if self.key in ('path', 'package'): if self.key == 'package': value = frame_data.get('package') or '' else: value = frame_data.get('abs_path') or frame_data.get( 'filename') or '' if glob_match(value, self.pattern, ignorecase=True, doublestar=True, path_normalize=True): return True if not value.startswith('/') and glob_match('/' + value, self.pattern, ignorecase=True, doublestar=True, path_normalize=True): return True return False # families need custom handling as well if self.key == 'family': flags = self.pattern.split(',') if 'all' in flags: return True family = get_grouping_family_for_platform( frame_data.get('platform') or platform) return family in flags # all other matches are case sensitive if self.key == 'function': from sentry.grouping.strategies.utils import trim_function_name value = trim_function_name( frame_data.get('function') or '<unknown>', frame_data.get('platform') or platform) elif self.key == 'module': value = frame_data.get('module') or '<unknown>' else: # should not happen :) value = '<unknown>' return glob_match(value, self.pattern)
def test_get_grouping_family_for_platform(input, output): assert get_grouping_family_for_platform(input) == output
def is_native(meta): return get_grouping_family_for_platform(meta['event'].platform) == 'native'