Skip to content

Commit fa06bcb

Browse files
committed
fix: Do not raise if channels could not be instrumented
Fix getsentry#515
1 parent fb15e13 commit fa06bcb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sentry_sdk/integrations/django/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from django.core import signals
1010

1111
from sentry_sdk._types import MYPY
12-
from sentry_sdk.utils import HAS_REAL_CONTEXTVARS
12+
from sentry_sdk.utils import HAS_REAL_CONTEXTVARS, logger
1313

1414
if MYPY:
1515
from typing import Any
@@ -287,7 +287,10 @@ def _patch_channels():
287287
if not HAS_REAL_CONTEXTVARS:
288288
# We better have contextvars or we're going to leak state between
289289
# requests.
290-
raise RuntimeError(
290+
#
291+
# We cannot hard-raise here because channels may not be used at all in
292+
# the current process.
293+
logger.warning(
291294
"We detected that you are using Django channels 2.0. To get proper "
292295
"instrumentation for ASGI requests, the Sentry SDK requires "
293296
"Python 3.7+ or the aiocontextvars package from PyPI."

0 commit comments

Comments
 (0)