-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #8
- Loading branch information
Showing
6 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend | |
EMAIL_SENDGRID_REPLY_TO=[email protected] | ||
PYTHONUNBUFFERED=1 | ||
SECRET_KEY="django-insecure-l@1xnj747ei)9ex(0zkfyy6zv@&*=i$wi9722=ji7)+s^_kuvy" | ||
SENTRY_ENABLED=off | ||
SENTRY_DSN=dsn_example |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import sentry_sdk | ||
from django.apps import AppConfig | ||
from django.conf import settings | ||
from sentry_sdk.integrations.django import DjangoIntegration | ||
|
||
|
||
def traces_sampler(sampling_context): # pragma: no cover | ||
"""Select a sample rate off of the requested path. | ||
The root endpoint seemed to get hammered by some bot and ate a huge percent | ||
of transactions in a week. I don't care about that page right now, | ||
so ignore it. | ||
""" | ||
path = sampling_context.get("wsgi_environ", {}).get("PATH_INFO", "") | ||
if path == "/": | ||
return 0 | ||
|
||
return 1.0 | ||
|
||
|
||
class SentryConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "journal.sentry" | ||
|
||
def ready(self): # pragma: no cover | ||
"""Initialize Sentry. | ||
Sentry initialization is moved to an application ready timeframe | ||
because it triggers circular imports with settings when used with | ||
type checking when django-stubs is enabled. | ||
""" | ||
if not settings.SENTRY_ENABLED: | ||
return | ||
|
||
sentry_sdk.init( | ||
dsn=settings.SENTRY_DSN, | ||
integrations=[ | ||
DjangoIntegration(), | ||
], | ||
traces_sampler=traces_sampler, | ||
send_default_pii=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ django-allauth==0.54.0 | |
django-environ==0.10.0 | ||
django-extensions==3.2.3 | ||
gunicorn==20.1.0 | ||
sentry-sdk==1.28.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters