From ddea1e0947126be1d28638d459a5a3c051c5080e Mon Sep 17 00:00:00 2001 From: Diego Calvo Date: Wed, 9 Jun 2021 09:51:12 +0200 Subject: [PATCH] sentry --- back_latienda/settings/production.py | 23 +++++++++++++++++++++++ back_latienda/urls.py | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/back_latienda/settings/production.py b/back_latienda/settings/production.py index eafc231..aea3b61 100644 --- a/back_latienda/settings/production.py +++ b/back_latienda/settings/production.py @@ -1,4 +1,6 @@ from back_latienda.settings.base import * +import sentry_sdk +from sentry_sdk.integrations.django import DjangoIntegration from datetime import timedelta @@ -7,6 +9,27 @@ DEBUG = False ALLOWED_HOSTS = ['*'] +# Sentry +sentry_sdk.init( + dsn=os.getenv('SENTRY_DSN'), + integrations=[DjangoIntegration()], + + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + # We recommend adjusting this value in production, + traces_sample_rate=1.0, + + # If you wish to associate users to errors (assuming you are using + # django.contrib.auth) you may enable sending PII data. + send_default_pii=True, + + # By default the SDK will try to use the SENTRY_RELEASE + # environment variable, or infer a git commit + # SHA as release, however you may want to set + # something more human-readable. + # release="myapp@1.0.0", +) + # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases diff --git a/back_latienda/urls.py b/back_latienda/urls.py index 513cdf4..96a509f 100644 --- a/back_latienda/urls.py +++ b/back_latienda/urls.py @@ -28,6 +28,10 @@ from .routers import router admin.site.site_header = 'LaTiendaCOOP Administration' +# Trigger sentry test error +def trigger_error(request): + division_by_zero = 1 / 0 + urlpatterns = [ path('admin/', admin.site.urls), path('activate///',core_views.activate_user, name='activate_user'), @@ -52,4 +56,5 @@ urlpatterns = [ path('api/v1/stats/me/', stat_views.track_user, name='user-tracker'), path('api/v1/autocomplete/category-tag/', product_views.CategoryTagAutocomplete.as_view(), name='category-autocomplete'), path('api/v1/', include(router.urls)), + path('sentry-debug/', trigger_error), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)