Skip to content

Commit 72c1d07

Browse files
committed
chore(Sentry): set the environment and release
1 parent 335387f commit 72c1d07

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

benefits/settings.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Django settings for benefits project.
33
"""
44
import os
5+
from benefits import VERSION
56
import benefits.logging
67
import sentry_sdk
78
from sentry_sdk.integrations.django import DjangoIntegration
@@ -233,18 +234,17 @@ def _filter_empty(ls):
233234
if SENTRY_DSN:
234235
print("Enabling Sentry…")
235236

237+
SENTRY_ENVIRONMENT = os.environ.get("SENTRY_ENVIRONMENT", "local")
238+
239+
# https://docs.sentry.io/platforms/python/configuration/
236240
sentry_sdk.init(
237241
dsn=SENTRY_DSN,
238242
integrations=[
239243
DjangoIntegration(),
240244
],
241-
# Set traces_sample_rate to 1.0 to capture 100%
242-
# of transactions for performance monitoring.
243-
# We recommend adjusting this value in production.
244245
traces_sample_rate=1.0,
245-
# If you wish to associate users to errors (assuming you are using
246-
# django.contrib.auth) you may enable sending PII data.
247-
send_default_pii=True,
246+
environment=SENTRY_ENVIRONMENT,
247+
release=VERSION,
248248
)
249249
else:
250250
print("SENTRY_DSN not set, so won't send events")

docs/configuration/environment-variables.md

+8
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,11 @@ Enables [log collection](../../deployment/troubleshooting/#logs). Set the value
181181
[Data Source Name (DSN)](https://docs.sentry.io/product/sentry-basics/dsn-explainer/)
182182

183183
Enables [sending events to Sentry](../../deployment/troubleshooting/#error-monitoring).
184+
185+
### `SENTRY_ENVIRONMENT`
186+
187+
!!! tldr "Sentry docs"
188+
189+
[`environment` config value](https://docs.sentry.io/platforms/python/configuration/options/#environment)
190+
191+
Segments errors by which deployment they occur in. This defaults to `local`, and can be set to match one of the [environment names](../../deployment/infrastructure/#environments).

0 commit comments

Comments
 (0)