Skip to content

Commit

Permalink
Merge pull request #63 from dimagi/ce/sentry
Browse files Browse the repository at this point in the history
add sentry
  • Loading branch information
calellowitz authored Jan 3, 2025
2 parents ef06d49 + 4ef4fa5 commit 6b9396b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
31 changes: 30 additions & 1 deletion connectid/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
import logging
import os
import sentry_sdk

from pathlib import Path
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration, ignore_logger
from sentry_sdk.integrations.redis import RedisIntegration


# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -224,6 +231,11 @@

APP_HASH = "apphash"

SENTRY_DSN = None
SENTRY_ENVIRONMENT = "local"
SENTRY_TRACES_SAMPLE_RATE = 0.0


from .localsettings import *

# Firebase
Expand All @@ -237,4 +249,21 @@

CELERY_BROKER_URL = env.get("CELERY_BROKER_URL", default="redis://localhost:6379/0")


if SENTRY_DSN:
sentry_logging = LoggingIntegration(
level=logging.INFO, # Capture info and above as breadcrumbs
event_level=logging.ERROR, # Send errors as events
)
integrations = [
sentry_logging,
DjangoIntegration(),
CeleryIntegration(),
RedisIntegration(),
]

sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=integrations,
environment=SENTRY_ENVIRONMENT,
traces_sample_rate=SENTRY_TRACES_SAMPLE_RATE,
)
7 changes: 4 additions & 3 deletions requirements/requirements.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
celery
Django
django-axes[ipware]
django-oauth-toolkit
django-otp
django-phonenumber-field
djangorestframework
fcm-django>=2.2
gunicorn
phonenumberslite
psycopg2
redis
sentry-sdk[django]
twilio
zxcvbn
fcm-django>=2.2
redis
celery
11 changes: 9 additions & 2 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ cachetools==5.3.1
celery==5.4.0
# via -r requirements.in
certifi==2022.12.7
# via requests
# via
# requests
# sentry-sdk
cffi==1.15.1
# via cryptography
charset-normalizer==3.1.0
Expand Down Expand Up @@ -51,6 +53,7 @@ django==4.1.7
# django-phonenumber-field
# djangorestframework
# fcm-django
# sentry-sdk
django-axes[ipware]==6.0.3
# via -r requirements.in
django-ipware==5.0.0
Expand Down Expand Up @@ -169,6 +172,8 @@ requests==2.28.2
# twilio
rsa==4.9
# via google-auth
sentry-sdk[django]==2.19.2
# via -r requirements.in
six==1.16.0
# via python-dateutil
sqlparse==0.4.3
Expand All @@ -184,7 +189,9 @@ tzdata==2024.2
uritemplate==4.1.1
# via google-api-python-client
urllib3==1.26.15
# via requests
# via
# requests
# sentry-sdk
vine==5.1.0
# via
# amqp
Expand Down

0 comments on commit 6b9396b

Please sign in to comment.