-
Notifications
You must be signed in to change notification settings - Fork 514
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
Ensure RedisIntegration
is disabled, unless redis
is installed
#2504
Ensure RedisIntegration
is disabled, unless redis
is installed
#2504
Conversation
tests/test_api.py
Outdated
@pytest.mark.skipif(REDIS_INSTALLED, reason="skipping because redis is installed") | ||
def test_redis_disabled_when_not_installed(sentry_init): | ||
sentry_init() | ||
|
||
assert Hub.current.get_integration(RedisIntegration) is None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unsure about in which file this test should be placed. Is it ok to keep here, or should it go somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe test_basics.py
would be better? It already has some tests for integration enabling.
test_api.py
is more for testing the global API (configure_scope
, start_transaction
, etc.; the stuff we surface via
sentry-python/sentry_sdk/__init__.py
Lines 13 to 43 in cb7299a
__all__ = [ # noqa | |
"Hub", | |
"Scope", | |
"Client", | |
"Transport", | |
"HttpTransport", | |
"init", | |
"integrations", | |
# From sentry_sdk.api | |
"capture_event", | |
"capture_message", | |
"capture_exception", | |
"add_breadcrumb", | |
"configure_scope", | |
"push_scope", | |
"flush", | |
"last_event_id", | |
"start_span", | |
"start_transaction", | |
"set_tag", | |
"set_context", | |
"set_extra", | |
"set_user", | |
"set_level", | |
"set_measurement", | |
"get_current_span", | |
"get_traceparent", | |
"get_baggage", | |
"continue_trace", | |
"trace", | |
] |
@szokeasaurusrex If I understood the issue correctly, the underlying problem is that in the Redis integration we raise sentry-python/sentry_sdk/integrations/redis/__init__.py Lines 275 to 278 in cb7299a
|
@sentrivana Apparently it is also a more general issue. Integrations which conditionally raise
So, raising |
@szokeasaurusrex Gotcha, I see now. We still raise I'll give this a proper review tomorrow 👍🏻 |
Yes, and this is precisely the reason why the change here is needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this!
tests/integrations/test_init.py
Outdated
return type(__value) == type(self) | ||
|
||
|
||
def test_multiple_setup_integrations_calls(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sentrivana Do you think this new file is an appropriate place for this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just put it in tests/test_basics.py
since we already have some integration tests in there?
Or maybe we could rename this new file from test_init.py
to something more generic like test_common.py
and also move other integrations-related tests from test_basics.py
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll put it in test_basics.py
for now. Maybe in the future we could split out into a separate file, but I think moving everything over would be out of scope for this issue
@sentrivana I added a test to check that multiple |
Thanks for the fix! and for ensuring it covers everything I detailed in the issue 👍 |
This PR fixes a bug where the
RedisIntegration
was showing up in the list of enabled integrations even whenredis
was not installed, and the integration should have been disabled.Fixes #1734