getsentry / raven-python

Raven is the legacy Python client for Sentry (getsentry.com) — replaced by sentry-python
https://sentry.io
BSD 3-Clause "New" or "Revised" License
1.68k stars 658 forks source link

Add support for Eve #952

Open gmargari opened 7 years ago

gmargari commented 7 years ago

Even though Eve is a wrapper around Flask, using sentry on Eve throws an exception, e.g.:

# app.py
from eve import Eve
from raven.contrib.flask import Sentry

app = Eve()
sentry = Sentry(app, dsn='...')
app.run()
Traceback (most recent call last):
  File "flask-sentry.py", line 5, in <module>
    sentry = Sentry(app, dsn='https://ccbeb003ed194f0bab837d8c33269cef:ad3c0bdbe07740799fcf3a30fe491449@sentry.io/136957')
  File "MYPATH/env/lib/python3.5/site-packages/raven/contrib/flask.py", line 114, in __init__
    self.init_app(app)
  File "MYPATH/env/lib/python3.5/site-packages/raven/contrib/flask.py", line 284, in init_app
    got_request_exception.connect(self.handle_exception, sender=app)
  File "MYPATH/env/lib/python3.5/site-packages/blinker/base.py", line 130, in connect
    sender_ref = reference(sender, self._cleanup_sender)
  File "MYPATH/env/lib/python3.5/site-packages/blinker/_utilities.py", line 134, in reference
    weak = callable_reference(object, callback)
  File "MYPATH/env/lib/python3.5/site-packages/blinker/_utilities.py", line 145, in callable_reference
    return BoundMethodWeakref(target=object, on_delete=callback)
  File "MYPATH/env/lib/python3.5/site-packages/blinker/_saferef.py", line 135, in __new__
    key = cls.calculate_key(target)
  File "MYPATH/env/lib/python3.5/site-packages/blinker/_saferef.py", line 196, in calculate_key
    return (id(get_self(target)), id(get_func(target)))
  File "MYPATH/env/lib/python3.5/site-packages/events/events.py", line 41, in __getattr__
    (self.__class__.__name__, name))
AttributeError: type object 'Eve' has no attribute '__self__'
Sentry is attempting to send 1 pending error messages
Waiting up to 10 seconds
Press Ctrl-C to quit
chasingrainbows commented 7 years ago

+1 We need it a lot thnx

astoliarov commented 7 years ago

+1

lvieirajr commented 7 years ago

+1

Ziul commented 7 years ago

No updates about it yet?

fernandocamargoai commented 6 years ago

A workaround for this problem is to subclass Eve as follows:

class BlinkerCompatibleEve(Eve):
    """
    Workaround for https://github.com/pyeve/eve/issues/1087
    """
    def __getattr__(self, name):
        if name in {"im_self", "im_func"}:
            raise AttributeError("type object '%s' has no attribute '%s'" %
                                 (self.__class__.__name__, name))
        return super(BlinkerCompatibleEve, self).__getattr__(name)