Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardcode eventlet transport rather than relying on dsn prefix #15

Merged
merged 1 commit into from
Feb 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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