Skip to content

Commit 70980e8

Browse files
committed
Add conditional, use integrations
1 parent edc59ad commit 70980e8

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/signal_documentation/settings.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,23 @@
1515
from typing import Any
1616

1717
# Sentry init and config:
18-
# - Specify the DSN via the env var of `SENTRY_DSN`.
18+
# - If you want to use Sentry, specify the DSN via the env var of `SENTRY_DSN`.
1919
# - Useful defaults for a development environment are set below. They can be
2020
# changed by modifying env vars.
21-
sentry_sdk.init(
22-
traces_sample_rate=os.environ.get('SENTRY_TRACES_SAMPLE_RATE', 1.0),
23-
profiles_sample_rate=os.environ.get('SENTRY_PROFILES_SAMPLE_RATE', 1.0),
24-
environment=os.environ.get('SENTRY_ENVIRONMENT', 'development'),
25-
debug=os.environ.get('SENTRY_DEBUG', 'True'),
26-
attach_stacktrace=os.environ.get('SENTRY_ATTACH_STACKTRACE', 'True')
27-
)
21+
from sentry_sdk.integrations.django import DjangoIntegration
22+
from sentry_sdk.integrations.redis import RedisIntegration
23+
24+
SENTRY_DSN = os.environ.get('SENTRY_DSN')
25+
if SENTRY_DSN:
26+
sentry_sdk.init(
27+
dsn=SENTRY_DSN,
28+
integrations=[DjangoIntegration(), RedisIntegration(max_data_size=0)],
29+
traces_sample_rate=os.environ.get('SENTRY_TRACES_SAMPLE_RATE', 1.0),
30+
profiles_sample_rate=os.environ.get('SENTRY_PROFILES_SAMPLE_RATE', 1.0),
31+
environment=os.environ.get('SENTRY_ENVIRONMENT', 'development'),
32+
debug=os.environ.get('SENTRY_DEBUG', 'True'),
33+
attach_stacktrace=os.environ.get('SENTRY_ATTACH_STACKTRACE', 'True')
34+
)
2835

2936

3037
# Build paths inside the project like this: BASE_DIR / 'subdir'.

0 commit comments

Comments
 (0)