Skip to content

Commit 6e2657a

Browse files
committed
fix: Auto-enabling Redis and Pyramid integration
1 parent 3a7f4f2 commit 6e2657a

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

sentry_sdk/integrations/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def iter_default_integrations(with_auto_enabling_integrations):
6363
"sentry_sdk.integrations.aiohttp.AioHttpIntegration",
6464
"sentry_sdk.integrations.tornado.TornadoIntegration",
6565
"sentry_sdk.integrations.sqlalchemy.SqlalchemyIntegration",
66+
"sentry_sdk.integrations.redis.RedisIntegration",
67+
"sentry_sdk.integrations.pyramid.PyramidIntegration",
6668
)
6769

6870

sentry_sdk/integrations/pyramid.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44
import sys
55
import weakref
66

7-
from pyramid.httpexceptions import HTTPException
8-
from pyramid.request import Request
9-
107
from sentry_sdk.hub import Hub, _should_send_default_pii
118
from sentry_sdk.utils import capture_internal_exceptions, event_from_exception
129
from sentry_sdk._compat import reraise, iteritems
1310

14-
from sentry_sdk.integrations import Integration
11+
from sentry_sdk.integrations import Integration, DidNotEnable
1512
from sentry_sdk.integrations._wsgi_common import RequestExtractor
1613
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
1714

15+
try:
16+
from pyramid.httpexceptions import HTTPException
17+
from pyramid.request import Request
18+
except ImportError:
19+
raise DidNotEnable("Pyramid not installed")
20+
1821
from sentry_sdk._types import MYPY
1922

2023
if MYPY:
@@ -64,7 +67,6 @@ def __init__(self, transaction_style="route_name"):
6467
def setup_once():
6568
# type: () -> None
6669
from pyramid import router
67-
from pyramid.request import Request
6870

6971
old_call_view = router._call_view
7072

sentry_sdk/integrations/redis.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from sentry_sdk import Hub
44
from sentry_sdk.utils import capture_internal_exceptions
5-
from sentry_sdk.integrations import Integration
5+
from sentry_sdk.integrations import Integration, DidNotEnable
66

77
from sentry_sdk._types import MYPY
88

@@ -16,7 +16,10 @@ class RedisIntegration(Integration):
1616
@staticmethod
1717
def setup_once():
1818
# type: () -> None
19-
import redis
19+
try:
20+
import redis
21+
except ImportError:
22+
raise DidNotEnable("Redis client not installed")
2023

2124
patch_redis_client(redis.StrictRedis)
2225

0 commit comments

Comments
 (0)