diff --git a/requirements.txt b/requirements.txt index 7fcb213..fdfd4d7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,6 +23,7 @@ python-dateutil==2.8.2 pytz==2022.1 redis==4.2.2 requests==2.27.1 +sentry-sdk==1.5.10 six==1.16.0 sqlparse==0.4.2 urllib3==1.26.9 diff --git a/shiftregister/settings.py b/shiftregister/settings.py index 2129361..050b0dd 100644 --- a/shiftregister/settings.py +++ b/shiftregister/settings.py @@ -12,6 +12,9 @@ https://docs.djangoproject.com/en/4.0/ref/settings/ from pathlib import Path from os import getenv +import sentry_sdk +from sentry_sdk.integrations.celery import CeleryIntegration +from sentry_sdk.integrations.django import DjangoIntegration # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -25,8 +28,10 @@ SECRET_KEY = getenv( "SECRET_KEY", "django-insecure-pdgzgd_!w&&cfqc%r&!v_^6pgf!sza=2wim67()!(kaf7_6-5)" ) +ENVIRONMENT = getenv("ENVIRONMENT", "development") + # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = getenv("ENVIRONMENT", "development") != "production" +DEBUG = ENVIRONMENT == "development" ALLOWED_HOSTS = list(filter(lambda s: s != "", getenv("ALLOWED_HOSTS", "").split(","))) @@ -151,3 +156,12 @@ CELERY_BEAT_SCHEDULE = { } CELERY_BEAT_SCHEDULE_FILENAME = str(BASE_DIR / "storage" / "celerybeat-schedule") + +if getenv("SENTRY_DSN"): + sentry_sdk.init( + dsn=getenv("SENTRY_DSN"), + integrations=[CeleryIntegration(), DjangoIntegration()], + auto_session_tracking=False, + traces_sample_rate=0, + environment=ENVIRONMENT, + )