Add Sentry integration

pull/1/head
Luca 3 years ago
parent b82c01ec38
commit 9032968bc0

@ -23,6 +23,7 @@ python-dateutil==2.8.2
pytz==2022.1 pytz==2022.1
redis==4.2.2 redis==4.2.2
requests==2.27.1 requests==2.27.1
sentry-sdk==1.5.10
six==1.16.0 six==1.16.0
sqlparse==0.4.2 sqlparse==0.4.2
urllib3==1.26.9 urllib3==1.26.9

@ -12,6 +12,9 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
from pathlib import Path from pathlib import Path
from os import getenv 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'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent 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)" "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! # 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(","))) 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") 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,
)

Loading…
Cancel
Save