Skip to content

Commit

Permalink
add sentry configs
Browse files Browse the repository at this point in the history
  • Loading branch information
jsatt committed Aug 25, 2020
1 parent 97a7978 commit 5e14ffe
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ DEBUG=True
#LOG_FORMAT=
#LOG_FORMATTER=plain
#LOG_LEVEL=DEBUG
#SENTRY_DSN=
#SENTRY_ENVIRONMENT=development
#SENTRY_EVENT_LEVEL=ERROR
#SENTRY_LOG_LEVEL=INFO
#USE_DATADOG=True
#USE_SENTRY=True
26 changes: 26 additions & 0 deletions base_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
BASE_URL = env.str('BASE_URL', default='localhost')
TESTING = env.bool('TESTING', default=False)
USE_DATADOG = env.bool('USE_DATADOG', default=False)
USE_SENTRY = env.bool('USE_SENTRY', default=False)

#########
# DJANGO SETTINGS
Expand Down Expand Up @@ -183,6 +184,31 @@
cache_logger_on_first_use=True,
)

#########
# SENTRY
#########
if USE_SENTRY:
import sentry_sdk
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration

logging_integration = LoggingIntegration(
level=getattr(logging, env.str('SENTRY_LOG_LEVEL', default='INFO')),
event_level=getattr(logging, env.str('SENTRY_EVENT_LEVEL', default='ERROR')),
)

sentry_sdk.init(
dsn=env.str('SENTRY_DSN', default=''),
environment=env.str('SENTRY_ENVIRONMENT', default='development'),
integrations=[
DjangoIntegration(),
CeleryIntegration(),
logging_integration,
],
send_default_pii=True,
)

#########
# DATADOG
#########
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ uvicorn
# tracking
datadog
ddtrace
sentry-sdk

# tests, linting, code quality
bandit
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ ignore_missing_imports = true
[mypy-pythonjsonlogger.*]
ignore_missing_imports = true

[mypy-sentry_sdk.*]
ignore_missing_imports = true

[mypy-structlog.*]
ignore_missing_imports = true

Expand Down

0 comments on commit 5e14ffe

Please sign in to comment.