Skip to content

Commit

Permalink
Merge pull request #15 from mattbennett/eventlet-transport
Browse files Browse the repository at this point in the history
hardcode eventlet transport rather than relying on dsn prefix
  • Loading branch information
mattbennett committed Feb 7, 2018
2 parents 172cb0f + a11d29f commit 99f9dc4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 3 additions & 1 deletion nameko_sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from nameko.web.handlers import HttpRequestHandler
from raven import Client
from raven.utils.wsgi import get_environ, get_headers
from raven.transport.eventlet import EventletHTTPTransport
from six.moves.urllib.parse import urlsplit # pylint: disable=E0401
from werkzeug.exceptions import ClientDisconnected

Expand All @@ -26,7 +27,8 @@ def setup(self):
sentry_config = sentry_config or {}
dsn = sentry_config.get('DSN', None)
kwargs = sentry_config.get('CLIENT_CONFIG', {})
self.client = Client(dsn, **kwargs)

self.client = Client(dsn, transport=EventletHTTPTransport, **kwargs)

report_expected_exceptions = sentry_config.get(
'REPORT_EXPECTED_EXCEPTIONS', True
Expand Down
26 changes: 25 additions & 1 deletion test_nameko_sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def config(rabbit_config):
config = rabbit_config.copy()
config.update({
'SENTRY': {
'DSN': 'eventlet+http://user:pass@localhost:9000/1',
'DSN': 'http://user:pass@localhost:9000/1',
'CLIENT_CONFIG': {
'site': 'site name'
}
Expand Down Expand Up @@ -66,6 +66,30 @@ def patched_sentry():
yield


@pytest.mark.parametrize("dsn", [
'http://user:pass@localhost:9000/1',
'eventlet+http://user:pass@localhost:9000/1',
])
def test_eventlet_transport(
dsn, rabbit_config, container_factory, service_cls
):
config = rabbit_config.copy()
config.update({
'SENTRY': {
'DSN': dsn
}
})

container = container_factory(service_cls, config)
container.start()

sentry = get_extension(container, SentryReporter)

# transport set correctly
transport = sentry.client.remote.get_transport()
assert isinstance(transport, EventletHTTPTransport)


@pytest.mark.usefixtures('patched_sentry')
def test_setup(container_factory, service_cls, config):

Expand Down

0 comments on commit 99f9dc4

Please sign in to comment.