Nameko-sentry: can't report to sentry

Hello!

I tried to send reports to sentry from my nameko-app with nameko-sentry and It wasn’t succesful. I tried Python3.8.1 and Python3.6.9 with the same result. I generated DSN on my sentry.io account and put it into config.yaml. After this I just copied official example code from nameko-sentry git repository and run it:
# service.py

from nameko.web.handlers import http
from nameko_sentry import SentryReporter
class Service(object):
    name = "demo"

    sentry = SentryReporter()

    @http("GET", "/broken")
    def broken(self, request):
        raise SomeException("boom")

I can’t see any result in sentry.io after raising SomeExcepton(‘boom’) or simple Exception(‘boom’).
But when I using sentry_sdk.capture_exception directly with the same DSN I can see new reports in sentry.io. What I’m doing wrong with nameko-sentry?

Is your config like this?

SENTRY:
        DSN: eventlet+${SENTRY_DSN:https://user:pass@localhost/00000}

@ksimmi I think the problem here is that the legacy Raven client has finally stopped being supported.

nameko-sentry needs an upgrade to the newer sentry-sdk. There has been some effort to do this, but I guess it’s urgent now.

It was me who started the mentioned Github issue and I apologize for not moving forward. I couldn’t get the tests to deterministically pass or fail and they don’t run on Travis CI (there’s a PR that fixes that part).

However, this is curious. We’re using nameko_sentry in production and it still works for us. For example:

from nameko.rpc import rpc
from nameko.web.handlers import http
from nameko_sentry import SentryReporter


class Service:
    name = "crasher_service"
    sentry = SentryReporter()

    @rpc
    def crash(self):
        raise Exception("oops, I crashed")

    @http("GET", "/")
    def crash_http(self, request):
        raise Exception("http crashed")

Both RPC and HTTP exceptions get logged to our Sentry instance. This is under Python 3.6.6 with the following dependencies:

$ pip freeze
amqp==2.6.0
certifi==2020.6.20
chardet==3.0.4
dnspython==1.16.0
eventlet==0.25.2
greenlet==0.4.16
idna==2.10
importlib-metadata==1.7.0
kombu==4.6.11
mock==4.0.2
monotonic==1.5
nameko==2.12.0
nameko-sentry==1.0.0
path==13.1.0
path.py==12.4.0
PyYAML==5.3.1
raven==6.10.0
requests==2.24.0
six==1.15.0
urllib3==1.25.9
vine==1.3.0
Werkzeug==1.0.1
wrapt==1.12.1
zipp==3.1.0

When I tried to run the same service under Python 3.8.1 with the same dependencies, indeed no exceptions were logged to Sentry. There’s still an unsolved eventlet issue with outgoing HTTPS requests on Python 3.7+, so perhaps that’s what happens somewhere within raven.
However this is no excuse not to switch from raven to sentry-sdk and I guess we should double down on that.

Ah, now you’ve reminded me about that eventlet issue, I remember downgrading to Py3.6 on a previous project to fix sentry reporting.

A curious workaround has since been discovered for that eventlet issue – installing PyOpenSSL version 19.1.0. This fixes eventlet, but I have not tested whether it solves this problem yet.

In any case, as you say, not an excuse not to switch from raven to sentry-sdk.

[Slightly OT] And yet that workaround doesn’t work in every case. I’ve had some small nameko services run just fine on Python 3.8, including posting to https:// URLs (with PyOpenSSL installed), while others crashed. However, this commit seems to fix the eventlet issue entirely (fingers crossed).

Update: I can confirm that installing eventlet from that commit seems to fix reporting to Sentry on Python 3.8 (in my crasher_service example).