Exemplo n.º 1
0
    def capture(self, exc_info=None, **kwargs):
        if not exc_info or exc_info is True:
            exc_info = sys.exc_info()

        if not exc_info:
            raise ValueError('No exception found')

        exc_type, exc_value, exc_traceback = exc_info

        try:
            frames = get_stack_info(
                iter_traceback_frames(exc_traceback),
                transformer=self.transform)

            exc_module = getattr(exc_type, '__module__', None)
            if exc_module:
                exc_module = str(exc_module)
            exc_type = getattr(exc_type, '__name__', '<unknown>')

            return {
                'level': kwargs.get('level', logging.ERROR),
                'sentry.interfaces.Exception': {
                    'value': to_unicode(exc_value),
                    'type': str(exc_type),
                    'module': to_unicode(exc_module),
                },
                'sentry.interfaces.Stacktrace': {
                    'frames': frames
                },
            }
        finally:
            try:
                del exc_type, exc_value, exc_traceback
            except Exception as e:
                self.logger.exception(e)
Exemplo n.º 2
0
    def capture(self, exc_info=None, **kwargs):
        if not exc_info or exc_info is True:
            exc_info = sys.exc_info()

        if not exc_info:
            raise ValueError('No exception found')

        exc_type, exc_value, exc_traceback = exc_info

        try:
            frames = get_stack_info(iter_traceback_frames(exc_traceback),
                                    transformer=self.transform)

            exc_module = getattr(exc_type, '__module__', None)
            if exc_module:
                exc_module = str(exc_module)
            exc_type = getattr(exc_type, '__name__', '<unknown>')

            return {
                'level': kwargs.get('level', logging.ERROR),
                'sentry.interfaces.Exception': {
                    'value': to_unicode(exc_value),
                    'type': str(exc_type),
                    'module': to_unicode(exc_module),
                },
                'sentry.interfaces.Stacktrace': {
                    'frames': frames
                },
            }
        finally:
            try:
                del exc_type, exc_value, exc_traceback
            except Exception as e:
                self.logger.exception(e)
Exemplo n.º 3
0
    def capture(self, exc_info=None, **kwargs):
        if not exc_info or exc_info is True:
            exc_info = sys.exc_info()

        if not exc_info:
            raise ValueError("No exception found")

        exc_type, exc_value, exc_traceback = exc_info

        try:
            frames = get_stack_info(iter_traceback_frames(exc_traceback), transformer=self.transform)

            exc_module = getattr(exc_type, "__module__", None)
            if exc_module:
                exc_module = str(exc_module)
            exc_type = getattr(exc_type, "__name__", "<unknown>")

            return {
                "level": logging.ERROR,
                "sentry.interfaces.Exception": {
                    "value": to_unicode(exc_value),
                    "type": str(exc_type),
                    "module": to_unicode(exc_module),
                },
                "sentry.interfaces.Stacktrace": {"frames": frames},
            }
        finally:
            try:
                del exc_type, exc_value, exc_traceback
            except Exception as e:
                self.logger.exception(e)
Exemplo n.º 4
0
 def before_request(self, *args, **kwargs):
     self.last_event_id = None
     try:
         self.client.http_context(self.get_http_info(request))
     except Exception as e:
         self.client.logger.exception(to_unicode(e))
     try:
         self.client.user_context(self.get_user_info(request))
     except Exception as e:
         self.client.logger.exception(to_unicode(e))
Exemplo n.º 5
0
 def format(self, result):
     result['message'] = to_unicode(
         result['message']
     )[:self.message_max_length] if result['message'] else None
     result['category'] = to_unicode(
         result['category']
     )[:CATEGORY_MAX_LENGTH] if result['category'] else None
     result['level'] = to_unicode(result['level'])[:LEVEL_MAX_LENGTH].lower(
     ) if result['level'] else None
     return result
Exemplo n.º 6
0
 def before_request(self, *args, **kwargs):
     self.last_event_id = None
     try:
         self.client.http_context(self.get_http_info(request))
     except Exception as e:
         self.client.logger.exception(to_unicode(e))
     try:
         self.client.user_context(self.get_user_info(request))
     except Exception as e:
         self.client.logger.exception(to_unicode(e))
Exemplo n.º 7
0
 def _get_value(self, exc_type, exc_value, exc_traceback):
     stack_info = get_stack_info(iter_traceback_frames(exc_traceback),
                                 transformer=self.transform,
                                 capture_locals=self.client.capture_locals)
     exc_module = getattr(exc_type, '__module__', None)
     if exc_module:
         exc_module = str(exc_module)
     exc_type = getattr(exc_type, '__name__', '<unknown>')
     return {
         'value': to_unicode(exc_value),
         'type': str(exc_type),
         'module': to_unicode(exc_module),
         'stacktrace': stack_info
     }
Exemplo n.º 8
0
 def capture(self, query, engine, **kwargs):
     return {
         self.name: {
             'query': to_unicode(query),
             'engine': str(engine),
         }
     }
Exemplo n.º 9
0
 def capture(self, query, engine, **kwargs):
     return {
         'sentry.interfaces.Query': {
             'query': to_unicode(query),
             'engine': str(engine),
         }
     }
Exemplo n.º 10
0
 def capture(self, query, engine, **kwargs):
     return {
         'sentry.interfaces.Query': {
             'query': to_unicode(query),
             'engine': str(engine),
         }
     }
Exemplo n.º 11
0
 def capture(self, query, engine, **kwargs):
     return {
         self.name: {
             'query': to_unicode(query),
             'engine': str(engine),
         }
     }
Exemplo n.º 12
0
 def handle_exception(self, *args, **kwargs):
     if not self.client:
         return
     try:
         self.client.user_context(self.get_user_info(request))
     except Exception as e:
         self.client.logger.exception(to_unicode(e))
     # print(g.token.user)
     self.captureException(exc_info=kwargs.get('exc_info'))
Exemplo n.º 13
0
    def before_request(self, *args, **kwargs):
        self.last_event_id = None

        if request.url_rule:
            self.client.transaction.push(request.url_rule.rule)

        try:
            self.client.http_context(self.get_http_info(request))
        except Exception as e:
            self.client.logger.exception(to_unicode(e))
Exemplo n.º 14
0
 def capture(self, message, params=(), formatted=None, **kwargs):
     message = to_unicode(message)
     data = {
         self.name: {
             'message': message,
             'params': self.transform(params),
         },
     }
     if 'message' not in data:
         data['message'] = formatted or message
     return data
Exemplo n.º 15
0
 def capture(self, message, params=(), formatted=None, **kwargs):
     message = to_unicode(message)
     data = {
         self.name: {
             'message': message,
             'params': self.transform(params),
         },
     }
     if 'message' not in data:
         data['message'] = formatted or message
     return data
Exemplo n.º 16
0
    def _get_value(self, exc_type, exc_value, exc_traceback):
        """
        Convert exception info to a value for the values list.
        """
        stack_info = get_stack_info(
            iter_traceback_frames(exc_traceback),
            transformer=self.transform,
            capture_locals=self.client.capture_locals,
        )

        exc_module = getattr(exc_type, '__module__', None)
        if exc_module:
            exc_module = str(exc_module)
        exc_type = getattr(exc_type, '__name__', '<unknown>')

        return {
            'value': to_unicode(exc_value),
            'type': str(exc_type),
            'module': to_unicode(exc_module),
            'stacktrace': stack_info,
        }
Exemplo n.º 17
0
    def handle_exception(self, request, exception):
        if not self.client:
            return
        try:
            self.client.http_context(self.get_http_info(request))
        except Exception as e:
            self.client.logger.exception(to_unicode(e))

        # Since Sanic is restricted to Python 3, let's be explicit with what
        # we pass for exception info, rather than relying on sys.exc_info().
        exception_info = (type(exception), exception, exception.__traceback__)
        self.captureException(exc_info=exception_info)
Exemplo n.º 18
0
    def handle_exception(self, request, exception):
        if not self.client:
            return
        try:
            self.client.http_context(self.get_http_info(request))
        except Exception as e:
            self.client.logger.exception(to_unicode(e))

        # Since Sanic is restricted to Python 3, let's be explicit with what
        # we pass for exception info, rather than relying on sys.exc_info().
        exception_info = (type(exception), exception, exception.__traceback__)
        self.captureException(exc_info=exception_info)
Exemplo n.º 19
0
    def capture(self, exc_info=None, **kwargs):
        new_exc_info = False
        if not exc_info or exc_info is True:
            new_exc_info = True
            exc_info = sys.exc_info()

        if not exc_info:
            raise ValueError('No exception found')

        try:
            exc_type, exc_value, exc_traceback = exc_info

            frames = varmap(
                lambda k, v: shorten(v,
                                     string_length=self.client.
                                     string_max_length,
                                     list_length=self.client.list_max_length),
                get_stack_info(iter_traceback_frames(exc_traceback)))

            culprit = get_culprit(frames, self.client.include_paths,
                                  self.client.exclude_paths)

            exc_module = getattr(exc_type, '__module__', None)
            exc_type = getattr(exc_type, '__name__', '<unknown>')
        finally:
            if new_exc_info:
                try:
                    del exc_info
                    del exc_traceback
                except Exception as e:
                    self.logger.exception(e)

        return {
            'level': logging.ERROR,
            'culprit': culprit,
            'sentry.interfaces.Exception': {
                'value': to_unicode(exc_value),
                'type': str(exc_type),
                'module': str(exc_module),
            },
            'sentry.interfaces.Stacktrace': {
                'frames': frames
            },
        }
Exemplo n.º 20
0
    def capture(self, exc_info=None, **kwargs):
        new_exc_info = False
        if not exc_info or exc_info is True:
            new_exc_info = True
            exc_info = sys.exc_info()

        if not exc_info:
            raise ValueError('No exception found')

        try:
            exc_type, exc_value, exc_traceback = exc_info

            frames = varmap(lambda k, v: shorten(v,
                string_length=self.client.string_max_length, list_length=self.client.list_max_length),
            get_stack_info(iter_traceback_frames(exc_traceback),
                list_max_length=self.client.list_max_length,
                string_max_length=self.client.string_max_length))

            exc_module = getattr(exc_type, '__module__', None)
            if exc_module:
                exc_module = str(exc_module)
            exc_type = getattr(exc_type, '__name__', '<unknown>')
        finally:
            if new_exc_info:
                try:
                    del exc_info
                    del exc_traceback
                except Exception as e:
                    self.logger.exception(e)

        return {
            'level': logging.ERROR,
            'sentry.interfaces.Exception': {
                'value': to_unicode(exc_value),
                'type': str(exc_type),
                'module': exc_module,
            },
            'sentry.interfaces.Stacktrace': {
                'frames': frames
            },
        }
Exemplo n.º 21
0
 def serialize(self, value):
     return to_unicode(value)
Exemplo n.º 22
0
 def format(self, result):
     result['message'] = to_unicode(result['message'])[:self.message_max_length] if result['message'] else None
     result['category'] = to_unicode(result['category'])[:CATEGORY_MAX_LENGTH] if result['category'] else None
     result['level'] = to_unicode(result['level'])[:LEVEL_MAX_LENGTH].lower() if result['level'] else None
     return result
Exemplo n.º 23
0
    def build_msg(self, event_type, data=None, date=None,
                  time_spent=None, extra=None, stack=None, public_key=None,
                  tags=None, **kwargs):
        """
        Captures, processes and serializes an event into a dict object

        The result of ``build_msg`` should be a standardized dict, with
        all default values available.
        """

        # create ID client-side so that it can be passed to application
        event_id = uuid.uuid4().hex

        if data is None:
            data = {}
        if extra is None:
            extra = {}
        if not date:
            date = datetime.datetime.utcnow()
        if stack is None:
            stack = self.auto_log_stacks

        if '.' not in event_type:
            # Assume it's a builtin
            event_type = 'raven.events.%s' % event_type

        handler = self.get_handler(event_type)
        result = handler.capture(**kwargs)

        # data (explicit) culprit takes over auto event detection
        culprit = result.pop('culprit', None)
        if data.get('culprit'):
            culprit = data['culprit']

        for k, v in six.iteritems(result):
            if k not in data:
                data[k] = v

        if stack and 'sentry.interfaces.Stacktrace' not in data:
            if stack is True:
                frames = iter_stack_frames()

            else:
                frames = stack

            data.update({
                'sentry.interfaces.Stacktrace': {
                    'frames': get_stack_info(frames,
                        transformer=self.transform)
                },
            })

        if 'sentry.interfaces.Stacktrace' in data:
            if self.include_paths:
                for frame in data['sentry.interfaces.Stacktrace']['frames']:
                    if frame.get('in_app') is not None:
                        continue

                    path = frame.get('module')
                    if not path:
                        continue

                    if path.startswith('raven.'):
                        frame['in_app'] = False
                    else:
                        frame['in_app'] = (
                            any(path.startswith(x) for x in self.include_paths)
                            and not
                            any(path.startswith(x) for x in self.exclude_paths)
                        )

            if not culprit:
                culprit = get_culprit(data['sentry.interfaces.Stacktrace']['frames'])

        if not data.get('level'):
            data['level'] = kwargs.get('level') or logging.ERROR

        if not data.get('server_name'):
            data['server_name'] = self.name

        if not data.get('modules'):
            data['modules'] = self.get_module_versions()

        data['tags'] = tags or {}
        data.setdefault('extra', {})
        data.setdefault('level', logging.ERROR)

        # Add default extra context
        if self.extra:
            for k, v in six.iteritems(self.extra):
                data['extra'].setdefault(k, v)

        # Add default tag context
        if self.tags:
            for k, v in six.iteritems(self.tags):
                data['tags'].setdefault(k, v)

        for k, v in six.iteritems(extra):
            data['extra'][k] = v

        if culprit:
            data['culprit'] = culprit

        # Run the data through processors
        for processor in self.get_processors():
            data.update(processor.process(data))

        if 'message' not in data:
            data['message'] = handler.to_string(data)

        data.setdefault('project', self.project)

        # Legacy support for site attribute
        site = data.pop('site', None) or self.site
        if site:
            data['tags'].setdefault('site', site)

        for key, value in six.iteritems(data['tags']):
            data['tags'][key] = to_unicode(value)

        # Make sure custom data is coerced
        for k, v in six.iteritems(data['extra']):
            data['extra'][k] = self.transform(v)

        # It's important date is added **after** we serialize
        data.update({
            'timestamp': date,
            'time_spent': time_spent,
            'event_id': event_id,
            'platform': PLATFORM_NAME,
        })

        return data
Exemplo n.º 24
0
class Exception(BaseEvent):
    """
    Exceptions store the following metadata:

    - value: 'My exception value'
    - type: 'ClassName'
    - module '__builtin__' (i.e. __builtin__.TypeError)
    - frames: a list of serialized frames (see _get_traceback_frames)
    """

    def to_string(self, data):
        exc = data['sentry.interfaces.Exception']
        if exc['value']:
            return '%s: %s' % (exc['type'], exc['value'])
        return exc['type']

    def get_hash(self, data):
        exc = data['sentry.interfaces.Exception']
        output = [exc['type']]
        for frame in data['sentry.interfaces.Stacktrace']['frames']:
            output.append(frame['module'])
            output.append(frame['function'])
        return output

    def capture(self, exc_info=None, **kwargs):
        new_exc_info = False
        if not exc_info or exc_info is True:
            new_exc_info = True
            exc_info = sys.exc_info()

        try:
            exc_type, exc_value, exc_traceback = exc_info

            frames = varmap(lambda k, v: shorten(v), get_stack_info(iter_traceback_frames(exc_traceback)))

            culprit = get_culprit(frames, self.client.include_paths, self.client.exclude_paths)

            if hasattr(exc_type, '__module__'):
                exc_module = exc_type.__module__
                exc_type = exc_type.__name__
            else:
                exc_module = None
                exc_type = exc_type.__name__
        finally:
            if new_exc_info:
                try:
                    del exc_info
                    del exc_traceback
                except Exception, e:
                    self.logger.exception(e)

        return {
            'level': logging.ERROR,
            'culprit': culprit,
            'sentry.interfaces.Exception': {
                'value': to_unicode(exc_value),
                'type': str(exc_type),
                'module': str(exc_module),
            },
            'sentry.interfaces.Stacktrace': {
                'frames': frames
            },
        }
Exemplo n.º 25
0
 def make_key(self, key):
     if not isinstance(key, six.string_types):
         return to_unicode(key)
     return key
Exemplo n.º 26
0
    def build_msg(self,
                  event_type,
                  data=None,
                  date=None,
                  time_spent=None,
                  extra=None,
                  stack=None,
                  public_key=None,
                  tags=None,
                  fingerprint=None,
                  **kwargs):
        """
        Captures, processes and serializes an event into a dict object

        The result of ``build_msg`` should be a standardized dict, with
        all default values available.
        """

        # create ID client-side so that it can be passed to application
        event_id = uuid.uuid4().hex

        data = merge_dicts(self.context.data, data)

        data.setdefault('tags', {})
        data.setdefault('extra', {})

        if '.' not in event_type:
            # Assume it's a builtin
            event_type = 'raven.events.%s' % event_type

        handler = self.get_handler(event_type)
        result = handler.capture(**kwargs)

        # data (explicit) culprit takes over auto event detection
        culprit = result.pop('culprit', None)
        if data.get('culprit'):
            culprit = data['culprit']

        for k, v in iteritems(result):
            if k not in data:
                data[k] = v

        # auto_log_stacks only applies to events that are not exceptions
        # due to confusion about which stack is which and the automatic
        # application of stacktrace to exception objects by Sentry
        if stack is None and 'exception' not in data:
            stack = self.auto_log_stacks

        if stack and 'stacktrace' not in data:
            if stack is True:
                frames = iter_stack_frames()

            else:
                frames = stack

            stack_info = get_stack_info(
                frames,
                transformer=self.transform,
                capture_locals=self.capture_locals,
            )
            data.update({
                'stacktrace': stack_info,
            })

        if self.include_paths:
            for frame in self._iter_frames(data):
                if frame.get('in_app') is not None:
                    continue

                path = frame.get('module')
                if not path:
                    continue

                if path.startswith('raven.'):
                    frame['in_app'] = False
                else:
                    frame['in_app'] = (any(
                        path.startswith(x)
                        for x in self.include_paths) and not any(
                            path.startswith(x) for x in self.exclude_paths))

        if not culprit:
            if 'stacktrace' in data:
                culprit = get_culprit(data['stacktrace']['frames'])
            elif 'exception' in data:
                stacktrace = data['exception']['values'][0].get('stacktrace')
                if stacktrace:
                    culprit = get_culprit(stacktrace['frames'])

        if not data.get('level'):
            data['level'] = kwargs.get('level') or logging.ERROR

        if not data.get('server_name'):
            data['server_name'] = self.name

        if not data.get('modules'):
            data['modules'] = self.get_module_versions()

        if self.release is not None:
            data['release'] = self.release

        if self.environment is not None:
            data['environment'] = self.environment

        data['tags'] = merge_dicts(self.tags, data['tags'], tags)
        data['extra'] = merge_dicts(self.extra, data['extra'], extra)

        # Legacy support for site attribute
        site = data.pop('site', None) or self.site
        if site:
            data['tags'].setdefault('site', site)

        if culprit:
            data['culprit'] = culprit

        if fingerprint:
            data['fingerprint'] = fingerprint

        # Run the data through processors
        for processor in self.get_processors():
            data.update(processor.process(data))

        if 'message' not in data:
            data['message'] = kwargs.get('message', handler.to_string(data))

        # tags should only be key=>u'value'
        for key, value in iteritems(data['tags']):
            data['tags'][key] = to_unicode(value)

        # extra data can be any arbitrary value
        for k, v in iteritems(data['extra']):
            data['extra'][k] = self.transform(v)

        # It's important date is added **after** we serialize
        data.setdefault('project', self.remote.project)
        data.setdefault('timestamp', date or datetime.utcnow())
        data.setdefault('time_spent', time_spent)
        data.setdefault('event_id', event_id)
        data.setdefault('platform', PLATFORM_NAME)
        data.setdefault('sdk', SDK_VALUE)

        # insert breadcrumbs
        if self.enable_breadcrumbs:
            crumbs = self.context.breadcrumbs.get_buffer()
            if crumbs:
                # Make sure we send the crumbs here as "values" as we use the
                # raven client internally in sentry and the alternative
                # submission option of a list here is not supported by the
                # internal sender.
                data.setdefault('breadcrumbs', {'values': crumbs})

        return data
Exemplo n.º 27
0
 def capture(self, message, params=(), formatted=None, **kwargs):
     message = to_unicode(message)
     data = {"sentry.interfaces.Message": {"message": message, "params": self.transform(params)}}
     if "message" not in data:
         data["message"] = formatted or message
     return data
Exemplo n.º 28
0
 def _log_exception(self, ex):
     self.client.logger.exception(to_unicode(ex))
Exemplo n.º 29
0
    def build_msg(self,
                  event_type,
                  data=None,
                  date=None,
                  time_spent=None,
                  extra=None,
                  stack=None,
                  public_key=None,
                  tags=None,
                  **kwargs):
        """
        Captures, processes and serializes an event into a dict object

        The result of ``build_msg`` should be a standardized dict, with
        all default values available.
        """

        # create ID client-side so that it can be passed to application
        event_id = uuid.uuid4().hex

        if data is None:
            data = {}
        if extra is None:
            extra = {}
        if not date:
            date = datetime.datetime.utcnow()
        if stack is None:
            stack = self.auto_log_stacks

        if '.' not in event_type:
            # Assume it's a builtin
            event_type = 'raven.events.%s' % event_type

        handler = self.get_handler(event_type)
        result = handler.capture(**kwargs)

        # data (explicit) culprit takes over auto event detection
        culprit = result.pop('culprit', None)
        if data.get('culprit'):
            culprit = data['culprit']

        for k, v in six.iteritems(result):
            if k not in data:
                data[k] = v

        if stack and 'sentry.interfaces.Stacktrace' not in data:
            if stack is True:
                frames = iter_stack_frames()

            else:
                frames = stack

            data.update({
                'sentry.interfaces.Stacktrace': {
                    'frames': get_stack_info(frames,
                                             transformer=self.transform)
                },
            })

        if 'sentry.interfaces.Stacktrace' in data:
            if self.include_paths:
                for frame in data['sentry.interfaces.Stacktrace']['frames']:
                    if frame.get('in_app') is not None:
                        continue

                    path = frame.get('module')
                    if not path:
                        continue

                    if path.startswith('raven.'):
                        frame['in_app'] = False
                    else:
                        frame['in_app'] = (any(
                            path.startswith(x) for x in self.include_paths)
                                           and not any(
                                               path.startswith(x)
                                               for x in self.exclude_paths))

            if not culprit:
                culprit = get_culprit(
                    data['sentry.interfaces.Stacktrace']['frames'])

        if not data.get('level'):
            data['level'] = kwargs.get('level') or logging.ERROR

        if not data.get('server_name'):
            data['server_name'] = self.name

        if not data.get('modules'):
            data['modules'] = self.get_module_versions()

        data['tags'] = tags or {}
        data.setdefault('extra', {})
        data.setdefault('level', logging.ERROR)

        # Add default extra context
        if self.extra:
            for k, v in six.iteritems(self.extra):
                data['extra'].setdefault(k, v)

        # Add default tag context
        if self.tags:
            for k, v in six.iteritems(self.tags):
                data['tags'].setdefault(k, v)

        for k, v in six.iteritems(extra):
            data['extra'][k] = v

        if culprit:
            data['culprit'] = culprit

        # Run the data through processors
        for processor in self.get_processors():
            data.update(processor.process(data))

        if 'message' not in data:
            data['message'] = handler.to_string(data)

        data.setdefault('project', self.project)

        # Legacy support for site attribute
        site = data.pop('site', None) or self.site
        if site:
            data['tags'].setdefault('site', site)

        for key, value in six.iteritems(data['tags']):
            data['tags'][key] = to_unicode(value)

        # Make sure custom data is coerced
        for k, v in six.iteritems(data['extra']):
            data['extra'][k] = self.transform(v)

        # It's important date is added **after** we serialize
        data.update({
            'timestamp': date,
            'time_spent': time_spent,
            'event_id': event_id,
            'platform': PLATFORM_NAME,
        })

        return data
Exemplo n.º 30
0
    def capture(self, event_type, data=None, date=None, time_spent=None, event_id=None,
                extra=None, stack=None, **kwargs):
        """
        Captures and processes an event and pipes it off to SentryClient.send.

        To use structured data (interfaces) with capture:

        >>> capture('Message', message='foo', data={
        >>>     'sentry.interfaces.Http': {
        >>>         'url': '...',
        >>>         'data': {},
        >>>         'query_string': '...',
        >>>         'method': 'POST',
        >>>     },
        >>>     'logger': 'logger.name',
        >>>     'site': 'site.name',
        >>> }, extra={
        >>>     'key': 'value',
        >>> })

        The finalized ``data`` structure contains the following (some optional) builtin values:

        >>> {
        >>>     # the culprit and version information
        >>>     'culprit': 'full.module.name', # or /arbitrary/path
        >>>
        >>>     # all detectable installed modules
        >>>     'modules': {
        >>>         'full.module.name': 'version string',
        >>>     },
        >>>
        >>>     # arbitrary data provided by user
        >>>     'extra': {
        >>>         'key': 'value',
        >>>     }
        >>> }

        :param event_type: the module path to the Event class. Builtins can use shorthand class
                           notation and exclude the full module path.
        :param tags: a list of tuples (key, value) specifying additional tags for event
        :param data: the data base, useful for specifying structured data interfaces. Any key which contains a '.'
                     will be assumed to be a data interface.
        :param date: the datetime of this event
        :param time_spent: a float value representing the duration of the event
        :param event_id: a 32-length unique string identifying this event
        :param extra: a dictionary of additional standard metadata
        :param culprit: a string representing the cause of this event (generally a path to a function)
        :return: a 32-length string identifying this event
        """
        if data is None:
            data = {}
        if extra is None:
            extra = {}
        if date is None:
            date = datetime.datetime.utcnow()
        if stack is None:
            stack = self.auto_log_stacks

        if '.' not in event_type:
            # Assume it's a builtin
            event_type = 'raven.events.%s' % event_type

        handler = self.get_handler(event_type)
        result = handler.capture(**kwargs)

        # data (explicit) culprit takes over auto event detection
        culprit = result.pop('culprit', None)
        if data.get('culprit'):
            culprit = data['culprit']

        for k, v in result.iteritems():
            if k not in data:
                data[k] = v
            else:
                data[k].update(v)

        if stack and 'sentry.interfaces.Stacktrace' not in data:
            if stack is True:
                frames = iter_stack_frames()

            else:
                frames = stack

            data.update({
                'sentry.interfaces.Stacktrace': {
                    'frames': varmap(lambda k, v: shorten(v), get_stack_info(frames))
                },
            })

        if 'sentry.interfaces.Stacktrace' in data and not culprit:
            culprit = get_culprit(data['sentry.interfaces.Stacktrace']['frames'], self.include_paths, self.exclude_paths)

        if not data.get('level'):
            data['level'] = logging.ERROR
        data['modules'] = get_versions(self.include_paths)
        data['server_name'] = self.name
        data.setdefault('extra', {})
        data.setdefault('level', logging.ERROR)

        # Shorten lists/strings
        for k, v in extra.iteritems():
            data['extra'][k] = shorten(v, string_length=self.string_max_length, list_length=self.list_max_length)

        if culprit:
            data['culprit'] = culprit

        checksum = hashlib.md5()
        for bit in handler.get_hash(data):
            checksum.update(to_unicode(bit) or '')
        data['checksum'] = checksum = checksum.hexdigest()

        # create ID client-side so that it can be passed to application
        event_id = uuid.uuid4().hex
        data['event_id'] = event_id

        # Run the data through processors
        for processor in self.get_processors():
            data.update(processor.process(data))

        # Make sure all data is coerced
        data = transform(data)

        if not date:
            date = datetime.datetime.utcnow()

        data['message'] = handler.to_string(data)

        data.update({
            'timestamp': date,
            'time_spent': time_spent,
            'event_id': event_id,
            'project': self.project,
        })

        self.send(**data)

        return (event_id, checksum)
Exemplo n.º 31
0
 def capture(self, query, engine, **kwargs):
     return {"sentry.interfaces.Query": {"query": to_unicode(query), "engine": str(engine)}}
Exemplo n.º 32
0
 def serialize(self, value):
     return to_unicode(value)
Exemplo n.º 33
0
    def capture(self, event_type, data=None, date=None, time_spent=None, event_id=None,
                extra=None, stack=None, **kwargs):
        """
        Captures and processes an event and pipes it off to SentryClient.send.

        To use structured data (interfaces) with capture:

        >>> capture('Message', message='foo', data={
        >>>     'sentry.interfaces.Http': {
        >>>         'url': '...',
        >>>         'data': {},
        >>>         'query_string': '...',
        >>>         'method': 'POST',
        >>>     },
        >>>     'logger': 'logger.name',
        >>>     'site': 'site.name',
        >>> }, extra={
        >>>     'key': 'value',
        >>> })

        The finalized ``data`` structure contains the following (some optional) builtin values:

        >>> {
        >>>     # the culprit and version information
        >>>     'culprit': 'full.module.name', # or /arbitrary/path
        >>>
        >>>     # all detectable installed modules
        >>>     'modules': {
        >>>         'full.module.name': 'version string',
        >>>     },
        >>>
        >>>     # arbitrary data provided by user
        >>>     'extra': {
        >>>         'key': 'value',
        >>>     }
        >>> }

        :param event_type: the module path to the Event class. Builtins can use shorthand class
                           notation and exclude the full module path.
        :param tags: a list of tuples (key, value) specifying additional tags for event
        :param data: the data base, useful for specifying structured data interfaces. Any key which contains a '.'
                     will be assumed to be a data interface.
        :param date: the datetime of this event
        :param time_spent: a float value representing the duration of the event
        :param event_id: a 32-length unique string identifying this event
        :param extra: a dictionary of additional standard metadata
        :param culprit: a string representing the cause of this event (generally a path to a function)
        :return: a 32-length string identifying this event
        """
        if data is None:
            data = {}
        if extra is None:
            extra = {}
        if date is None:
            date = datetime.datetime.utcnow()
        if stack is None:
            stack = self.auto_log_stacks

        if '.' not in event_type:
            # Assume it's a builtin
            event_type = 'raven.events.%s' % event_type

        handler = self.get_handler(event_type)
        result = handler.capture(**kwargs)

        # data (explicit) culprit takes over auto event detection
        culprit = result.pop('culprit', None)
        if data.get('culprit'):
            culprit = data['culprit']

        for k, v in result.iteritems():
            if k not in data:
                data[k] = v
            else:
                data[k].update(v)

        if stack and 'sentry.interfaces.Stacktrace' not in data:
            if stack is True:
                frames = iter_stack_frames()

            else:
                frames = stack

            data.update({
                'sentry.interfaces.Stacktrace': {
                    'frames': varmap(lambda k, v: shorten(v), get_stack_info(frames))
                },
            })

        if 'sentry.interfaces.Stacktrace' in data and not culprit:
            culprit = get_culprit(data['sentry.interfaces.Stacktrace']['frames'], self.include_paths, self.exclude_paths)

        if not data.get('level'):
            data['level'] = logging.ERROR
        data['modules'] = get_versions(self.include_paths)
        data['server_name'] = self.name
        data.setdefault('extra', {})
        data.setdefault('level', logging.ERROR)

        # Shorten lists/strings
        for k, v in extra.iteritems():
            data['extra'][k] = shorten(v, string_length=self.string_max_length, list_length=self.list_max_length)

        if culprit:
            data['culprit'] = culprit

        checksum = hashlib.md5()
        for bit in handler.get_hash(data):
            checksum.update(to_unicode(bit) or '')
        data['checksum'] = checksum = checksum.hexdigest()

        # create ID client-side so that it can be passed to application
        event_id = uuid.uuid4().hex
        data['event_id'] = event_id

        # Run the data through processors
        for processor in self.get_processors():
            data.update(processor.process(data))

        # Make sure all data is coerced
        data = transform(data)

        if not date:
            date = datetime.datetime.utcnow()

        data['message'] = handler.to_string(data)

        data.update({
            'timestamp': date,
            'time_spent': time_spent,
            'event_id': event_id,
            'project': self.project,
        })

        self.send(**data)

        return (event_id, checksum)
Exemplo n.º 34
0
 def make_key(self, key):
     if not isinstance(key, string_types):
         return to_unicode(key)
     return key
Exemplo n.º 35
0
    def build_msg(
        self,
        event_type,
        data=None,
        date=None,
        time_spent=None,
        extra=None,
        stack=None,
        public_key=None,
        tags=None,
        fingerprint=None,
        **kwargs
    ):
        """
        Captures, processes and serializes an event into a dict object

        The result of ``build_msg`` should be a standardized dict, with
        all default values available.
        """

        # create ID client-side so that it can be passed to application
        event_id = uuid.uuid4().hex

        data = merge_dicts(self.context.data, data)

        data.setdefault("tags", {})
        data.setdefault("extra", {})

        if "." not in event_type:
            # Assume it's a builtin
            event_type = "raven.events.%s" % event_type

        handler = self.get_handler(event_type)
        result = handler.capture(**kwargs)

        # data (explicit) culprit takes over auto event detection
        culprit = result.pop("culprit", None)
        if data.get("culprit"):
            culprit = data["culprit"]

        for k, v in six.iteritems(result):
            if k not in data:
                data[k] = v

        # auto_log_stacks only applies to events that are not exceptions
        # due to confusion about which stack is which and the automatic
        # application of stacktrace to exception objects by Sentry
        if stack is None and "exception" not in data:
            stack = self.auto_log_stacks

        if stack and "stacktrace" not in data:
            if stack is True:
                frames = iter_stack_frames()

            else:
                frames = stack

            stack_info = get_stack_info(frames, transformer=self.transform, capture_locals=self.capture_locals)
            data.update({"stacktrace": stack_info})

        if self.include_paths:
            for frame in self._iter_frames(data):
                if frame.get("in_app") is not None:
                    continue

                path = frame.get("module")
                if not path:
                    continue

                if path.startswith("raven."):
                    frame["in_app"] = False
                else:
                    frame["in_app"] = any(path.startswith(x) for x in self.include_paths) and not any(
                        path.startswith(x) for x in self.exclude_paths
                    )

        if not culprit:
            if "stacktrace" in data:
                culprit = get_culprit(data["stacktrace"]["frames"])
            elif "exception" in data:
                stacktrace = data["exception"]["values"][0].get("stacktrace")
                if stacktrace:
                    culprit = get_culprit(stacktrace["frames"])

        if not data.get("level"):
            data["level"] = kwargs.get("level") or logging.ERROR

        if not data.get("server_name"):
            data["server_name"] = self.name

        if not data.get("modules"):
            data["modules"] = self.get_module_versions()

        if self.release is not None:
            data["release"] = self.release

        data["tags"] = merge_dicts(self.tags, data["tags"], tags)
        data["extra"] = merge_dicts(self.extra, data["extra"], extra)

        # Legacy support for site attribute
        site = data.pop("site", None) or self.site
        if site:
            data["tags"].setdefault("site", site)

        if culprit:
            data["culprit"] = culprit

        if fingerprint:
            data["fingerprint"] = fingerprint

        # Run the data through processors
        for processor in self.get_processors():
            data.update(processor.process(data))

        if "message" not in data:
            data["message"] = kwargs.get("message", handler.to_string(data))

        # tags should only be key=>u'value'
        for key, value in six.iteritems(data["tags"]):
            data["tags"][key] = to_unicode(value)

        # extra data can be any arbitrary value
        for k, v in six.iteritems(data["extra"]):
            data["extra"][k] = self.transform(v)

        # It's important date is added **after** we serialize
        data.setdefault("project", self.remote.project)
        data.setdefault("timestamp", date or datetime.utcnow())
        data.setdefault("time_spent", time_spent)
        data.setdefault("event_id", event_id)
        data.setdefault("platform", PLATFORM_NAME)

        return data
Exemplo n.º 36
0
    def build_msg(self, event_type, data = None, date = None, time_spent = None, extra = None, stack = None, public_key = None, tags = None, fingerprint = None, **kwargs):
        event_id = uuid.uuid4().hex
        data = merge_dicts(self.context.data, data)
        data.setdefault('tags', {})
        data.setdefault('extra', {})
        if '.' not in event_type:
            event_type = 'raven.events.%s' % event_type
        handler = self.get_handler(event_type)
        result = handler.capture(**kwargs)
        culprit = result.pop('culprit', None)
        if data.get('culprit'):
            culprit = data['culprit']
        for k, v in iteritems(result):
            if k not in data:
                data[k] = v

        if stack is None and 'exception' not in data:
            stack = self.auto_log_stacks
        if stack and 'stacktrace' not in data:
            if stack is True:
                frames = iter_stack_frames()
            else:
                frames = stack
            stack_info = get_stack_info(frames, transformer=self.transform, capture_locals=self.capture_locals)
            data.update({'stacktrace': stack_info})
        if self.include_paths:
            for frame in self._iter_frames(data):
                if frame.get('in_app') is not None:
                    continue
                path = frame.get('module')
                if not path:
                    continue
                if path.startswith('raven.'):
                    frame['in_app'] = False
                else:
                    frame['in_app'] = any((path.startswith(x) for x in self.include_paths)) and not any((path.startswith(x) for x in self.exclude_paths))

        if not culprit:
            if 'stacktrace' in data:
                culprit = get_culprit(data['stacktrace']['frames'])
            elif 'exception' in data:
                stacktrace = data['exception']['values'][0].get('stacktrace')
                if stacktrace:
                    culprit = get_culprit(stacktrace['frames'])
        if not data.get('level'):
            data['level'] = kwargs.get('level') or logging.ERROR
        if not data.get('server_name'):
            data['server_name'] = self.name
        if not data.get('modules'):
            data['modules'] = self.get_module_versions()
        if self.release is not None:
            data['release'] = self.release
        if self.environment is not None:
            data['environment'] = self.environment
        data['tags'] = merge_dicts(self.tags, data['tags'], tags)
        data['extra'] = merge_dicts(self.extra, data['extra'], extra)
        site = data.pop('site', None) or self.site
        if site:
            data['tags'].setdefault('site', site)
        if culprit:
            data['culprit'] = culprit
        if fingerprint:
            data['fingerprint'] = fingerprint
        for processor in self.get_processors():
            data.update(processor.process(data))

        if 'message' not in data:
            data['message'] = kwargs.get('message', handler.to_string(data))
        for key, value in iteritems(data['tags']):
            data['tags'][key] = to_unicode(value)

        for k, v in iteritems(data['extra']):
            data['extra'][k] = self.transform(v)

        data.setdefault('project', self.remote.project)
        data.setdefault('timestamp', date or datetime.utcnow())
        data.setdefault('time_spent', time_spent)
        data.setdefault('event_id', event_id)
        data.setdefault('platform', PLATFORM_NAME)
        data.setdefault('sdk', SDK_VALUE)
        if self.enable_breadcrumbs:
            crumbs = self.context.breadcrumbs.get_buffer()
            if crumbs:
                data.setdefault('breadcrumbs', {'values': crumbs})
        return data
Exemplo n.º 37
0
 def serialize(self, value, **kwargs):
     string_max_length = kwargs.get('string_max_length', None)
     return to_unicode(value)[:string_max_length]
Exemplo n.º 38
0
    def build_msg(self, event_type, data=None, date=None,
                  time_spent=None, extra=None, stack=None, public_key=None,
                  tags=None, fingerprint=None, **kwargs):
        """
        Captures, processes and serializes an event into a dict object

        The result of ``build_msg`` should be a standardized dict, with
        all default values available.
        """

        # create ID client-side so that it can be passed to application
        event_id = uuid.uuid4().hex

        data = merge_dicts(self.context.data, data)

        data.setdefault('tags', {})
        data.setdefault('extra', {})

        if '.' not in event_type:
            # Assume it's a builtin
            event_type = 'raven.events.%s' % event_type

        handler = self.get_handler(event_type)
        result = handler.capture(**kwargs)

        # data (explicit) culprit takes over auto event detection
        culprit = result.pop('culprit', None)
        if data.get('culprit'):
            culprit = data['culprit']

        for k, v in iteritems(result):
            if k not in data:
                data[k] = v

        # auto_log_stacks only applies to events that are not exceptions
        # due to confusion about which stack is which and the automatic
        # application of stacktrace to exception objects by Sentry
        if stack is None and 'exception' not in data:
            stack = self.auto_log_stacks

        if stack and 'stacktrace' not in data:
            if stack is True:
                frames = iter_stack_frames()

            else:
                frames = stack

            stack_info = get_stack_info(
                frames,
                transformer=self.transform,
                capture_locals=self.capture_locals,
            )
            data.update({
                'stacktrace': stack_info,
            })

        if self.include_paths:
            for frame in self._iter_frames(data):
                if frame.get('in_app') is not None:
                    continue

                path = frame.get('module')
                if not path:
                    continue

                if path.startswith('raven.'):
                    frame['in_app'] = False
                else:
                    frame['in_app'] = (
                        any(path.startswith(x) for x in self.include_paths) and
                        not any(path.startswith(x) for x in self.exclude_paths)
                    )

        if not culprit:
            if 'stacktrace' in data:
                culprit = get_culprit(data['stacktrace']['frames'])
            elif 'exception' in data:
                stacktrace = data['exception']['values'][0].get('stacktrace')
                if stacktrace:
                    culprit = get_culprit(stacktrace['frames'])

        if not data.get('level'):
            data['level'] = kwargs.get('level') or logging.ERROR

        if not data.get('server_name'):
            data['server_name'] = self.name

        if not data.get('modules'):
            data['modules'] = self.get_module_versions()

        if self.release is not None:
            data['release'] = self.release

        if self.environment is not None:
            data['environment'] = self.environment

        data['tags'] = merge_dicts(self.tags, data['tags'], tags)
        data['extra'] = merge_dicts(self.extra, data['extra'], extra)

        # Legacy support for site attribute
        site = data.pop('site', None) or self.site
        if site:
            data['tags'].setdefault('site', site)

        if culprit:
            data['culprit'] = culprit

        if fingerprint:
            data['fingerprint'] = fingerprint

        # Run the data through processors
        for processor in self.get_processors():
            data.update(processor.process(data))

        if 'message' not in data:
            data['message'] = kwargs.get('message', handler.to_string(data))

        # tags should only be key=>u'value'
        for key, value in iteritems(data['tags']):
            data['tags'][key] = to_unicode(value)

        # extra data can be any arbitrary value
        for k, v in iteritems(data['extra']):
            data['extra'][k] = self.transform(v)

        # It's important date is added **after** we serialize
        data.setdefault('project', self.remote.project)
        data.setdefault('timestamp', date or datetime.utcnow())
        data.setdefault('time_spent', time_spent)
        data.setdefault('event_id', event_id)
        data.setdefault('platform', PLATFORM_NAME)

        return data
Exemplo n.º 39
0
 def serialize(self, value, **kwargs):
     string_max_length = kwargs.get('string_max_length', None)
     return to_unicode(value)[:string_max_length]
Exemplo n.º 40
0
class Exception(BaseEvent):
    """
    Exceptions store the following metadata:

    - value: 'My exception value'
    - type: 'ClassName'
    - module '__builtin__' (i.e. __builtin__.TypeError)
    - frames: a list of serialized frames (see _get_traceback_frames)
    """
    def to_string(self, data):
        exc = data['sentry.interfaces.Exception']
        if exc['value']:
            return '%s: %s' % (exc['type'], exc['value'])
        return exc['type']

    def get_hash(self, data):
        exc = data['sentry.interfaces.Exception']
        output = [exc['type']]
        for frame in data['sentry.interfaces.Stacktrace']['frames']:
            output.append(frame['module'])
            output.append(frame.get('context_line', frame['function']))
        return output

    def capture(self, exc_info=None, **kwargs):
        new_exc_info = False
        if not exc_info or exc_info is True:
            new_exc_info = True
            exc_info = sys.exc_info()

        if not exc_info:
            raise ValueError('No exception found')

        try:
            exc_type, exc_value, exc_traceback = exc_info

            frames = varmap(
                lambda k, v: shorten(v,
                                     string_length=self.client.
                                     string_max_length,
                                     list_length=self.client.list_max_length),
                get_stack_info(
                    iter_traceback_frames(exc_traceback),
                    list_max_length=self.client.list_max_length,
                    string_max_length=self.client.string_max_length))

            exc_module = getattr(exc_type, '__module__', None)
            if exc_module:
                exc_module = str(exc_module)
            exc_type = getattr(exc_type, '__name__', '<unknown>')
        finally:
            if new_exc_info:
                try:
                    del exc_info
                    del exc_traceback
                except Exception, e:
                    self.logger.exception(e)

        return {
            'level': logging.ERROR,
            'sentry.interfaces.Exception': {
                'value': to_unicode(exc_value),
                'type': str(exc_type),
                'module': exc_module,
            },
            'sentry.interfaces.Stacktrace': {
                'frames': frames
            },
        }
Exemplo n.º 41
0
    def build_msg(self, event_type, data=None, date=None,
                  time_spent=None, extra=None, stack=None, public_key=None,
                  tags=None, fingerprint=None, **kwargs):
        """
        Captures, processes and serializes an event into a dict object

        The result of ``build_msg`` should be a standardized dict, with
        all default values available.
        """
        # create ID client-side so that it can be passed to application
        event_id = uuid.uuid4().hex
        print("SENTRY_EVENT_ID: " + event_id)

        data = merge_dicts(self.context.data, data)

        data.setdefault('tags', {})
        data.setdefault('extra', {})

        if '.' not in event_type:
            # Assume it's a builtin
            event_type = 'raven.events.%s' % event_type

        handler = self.get_handler(event_type)
        result = handler.capture(**kwargs)

        # data (explicit) culprit takes over auto event detection
        culprit = result.pop('culprit', None)
        if data.get('culprit'):
            culprit = data['culprit']

        for k, v in iteritems(result):
            if k not in data:
                data[k] = v

        # auto_log_stacks only applies to events that are not exceptions
        # due to confusion about which stack is which and the automatic
        # application of stacktrace to exception objects by Sentry
        if stack is None and 'exception' not in data:
            stack = self.auto_log_stacks

        if stack and 'stacktrace' not in data:
            if stack is True:
                frames = iter_stack_frames()

            else:
                frames = stack

            stack_info = get_stack_info(
                frames,
                transformer=self.transform,
                capture_locals=self.capture_locals,
            )
            data.update({
                'stacktrace': stack_info,
            })

        if self.include_paths:
            for frame in self._iter_frames(data):
                if frame.get('in_app') is not None:
                    continue

                path = frame.get('module')
                if not path:
                    continue

                if path.startswith('raven.'):
                    frame['in_app'] = False
                else:
                    frame['in_app'] = (
                        any(path.startswith(x) for x in self.include_paths) and
                        not any(path.startswith(x) for x in self.exclude_paths)
                    )

        transaction = None
        if not culprit:
            transaction = self.transaction.peek()

        if not data.get('level'):
            data['level'] = kwargs.get('level') or logging.ERROR

        if not data.get('server_name'):
            data['server_name'] = self.name

        if not data.get('modules'):
            data['modules'] = self.get_module_versions()

        if self.release is not None:
            data['release'] = self.release

        if self.environment is not None:
            data['environment'] = self.environment

        data['tags'] = merge_dicts(self.tags, data['tags'], tags)
        data['extra'] = merge_dicts(self.extra, data['extra'], extra)

        # Legacy support for site attribute
        site = data.pop('site', None) or self.site
        if site:
            data['tags'].setdefault('site', site)

        if transaction:
            data['transaction'] = transaction
        elif culprit:
            data['culprit'] = culprit

        if fingerprint:
            data['fingerprint'] = fingerprint

        # Run the data through processors
        for processor in self.get_processors():
            data.update(processor.process(data))

        if 'message' not in data:
            data['message'] = kwargs.get('message', handler.to_string(data))

        # tags should only be key=>u'value'
        for key, value in iteritems(data['tags']):
            data['tags'][key] = to_unicode(value)

        # extra data can be any arbitrary value
        for k, v in iteritems(data['extra']):
            data['extra'][k] = self.transform(v)

        # It's important date is added **after** we serialize
        data.setdefault('project', self.remote.project)
        data.setdefault('timestamp', date or datetime.utcnow())
        data.setdefault('time_spent', time_spent)
        data.setdefault('event_id', event_id)
        data.setdefault('platform', PLATFORM_NAME)
        data.setdefault('sdk', SDK_VALUE)
        data.setdefault('repos', self.repos)

        # insert breadcrumbs
        if self.enable_breadcrumbs:
            crumbs = self.context.breadcrumbs.get_buffer()
            if crumbs:
                # Make sure we send the crumbs here as "values" as we use the
                # raven client internally in sentry and the alternative
                # submission option of a list here is not supported by the
                # internal sender.
                data.setdefault('breadcrumbs', {
                    'values': crumbs
                })

        frame = data['exception']['values'][0]['stacktrace']['frames'][0]
        if frame['vars']['SENTRY_CODE_SNIPPET'][0] == "'" and frame['vars']['SENTRY_CODE_SNIPPET'][-1] == "'":
            code = frame['vars']['SENTRY_CODE_SNIPPET'][1:-1]
        else:
            code = frame['vars']['SENTRY_CODE_SNIPPET']
        lineno = frame['lineno']
        frame['context_line'] = code.split('\n')[lineno - 1]
        frame['post_context'] = code.split('\n')[lineno:]
        frame['pre_context'] = code.split('\n')[:lineno - 1]
        for var in ['request', 'SENTRY_CODE_SNIPPET', 'SENTRY_STDOUT_SOCKET', 'SENTRY_STDOUT_FUNCTION']:
            frame['vars'].pop(var, None)

        return data