Commit 335387f 1 parent 3a5f7c2 commit 335387f Copy full SHA for 335387f
File tree 5 files changed +47
-0
lines changed
5 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -5,4 +5,5 @@ eligibility-api==2023.01.1
5
5
opencensus-ext-azure == 1.1.6
6
6
opencensus-ext-django == 0.8.0
7
7
requests == 2.28.2
8
+ sentry-sdk == 1.15.0
8
9
six == 1.16.0
Original file line number Diff line number Diff line change 3
3
"""
4
4
import os
5
5
import benefits .logging
6
+ import sentry_sdk
7
+ from sentry_sdk .integrations .django import DjangoIntegration
6
8
7
9
8
10
def _filter_empty (ls ):
@@ -227,6 +229,26 @@ def _filter_empty(ls):
227
229
LOG_LEVEL = os .environ .get ("DJANGO_LOG_LEVEL" , "DEBUG" if DEBUG else "WARNING" )
228
230
LOGGING = benefits .logging .get_config (LOG_LEVEL , enable_azure = ENABLE_AZURE_INSIGHTS )
229
231
232
+ SENTRY_DSN = os .environ .get ("SENTRY_DSN" )
233
+ if SENTRY_DSN :
234
+ print ("Enabling Sentry…" )
235
+
236
+ sentry_sdk .init (
237
+ dsn = SENTRY_DSN ,
238
+ integrations = [
239
+ DjangoIntegration (),
240
+ ],
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.
244
+ 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 ,
248
+ )
249
+ else :
250
+ print ("SENTRY_DSN not set, so won't send events" )
251
+
230
252
# Analytics configuration
231
253
232
254
ANALYTICS_KEY = os .environ .get ("ANALYTICS_KEY" )
Original file line number Diff line number Diff line change 16
16
handler404 = "benefits.core.views.page_not_found"
17
17
handler500 = "benefits.core.views.server_error"
18
18
19
+
20
+ # based on
21
+ # https://docs.sentry.io/platforms/python/guides/django/#verify
22
+ def trigger_error (request ):
23
+ raise RuntimeError ("Test error" )
24
+
25
+
19
26
urlpatterns = [
20
27
path ("" , include ("benefits.core.urls" )),
21
28
path ("eligibility/" , include ("benefits.eligibility.urls" )),
22
29
path ("enrollment/" , include ("benefits.enrollment.urls" )),
23
30
path ("i18n/" , include ("django.conf.urls.i18n" )),
24
31
path ("oauth/" , include ("benefits.oauth.urls" )),
32
+ path ("sentry-debug/" , trigger_error ),
25
33
]
26
34
27
35
if settings .ADMIN :
Original file line number Diff line number Diff line change @@ -171,3 +171,13 @@ Enables [log collection](../../deployment/troubleshooting/#logs). Set the value
171
171
[ app-service-config ] : https://docs.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal
172
172
[ benefits-secrets ] : https://github.com/cal-itp/benefits-secrets
173
173
[ getting-started_create-env ] : ../getting-started/README.md#create-an-environment-file
174
+
175
+ ## Sentry
176
+
177
+ ### ` SENTRY_DSN `
178
+
179
+ !!! tldr "Sentry docs"
180
+
181
+ [Data Source Name (DSN)](https://docs.sentry.io/product/sentry-basics/dsn-explainer/)
182
+
183
+ Enables [ sending events to Sentry] ( ../../deployment/troubleshooting/#error-monitoring ) .
Original file line number Diff line number Diff line change @@ -45,6 +45,12 @@ az webapp log tail --resource-group RG-CDT-PUB-VIP-CALITP-P-001 --name AS-CDT-PU
45
45
46
46
< https://as-cdt-pub-vip-calitp-p-001-dev.scm.azurewebsites.net/api/logs/docker >
47
47
48
+ ### Sentry
49
+
50
+ Cal-ITP's Sentry instance collects both [ errors ("Issues")] ( https://sentry.calitp.org/organizations/sentry/issues/?project=3 ) and app [ performance info] ( https://sentry.calitp.org/organizations/sentry/performance/?project=3 ) .
51
+
52
+ [ Alerts are sent to #benefits-notify in Slack.] ( https://sentry.calitp.org/organizations/sentry/alerts/rules/benefits/9/details/ ) [ Others can be configured.] ( https://sentry.calitp.org/organizations/sentry/alerts/rules/ )
53
+
48
54
## Specific issues
49
55
50
56
This section serves as the [ runbook] ( https://www.pagerduty.com/resources/learn/what-is-a-runbook/ ) for Benefits.
You can’t perform that action at this time.
0 commit comments