From 409e932c76d89ae3757c616a63e08261e65625aa Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Fri, 24 Apr 2020 12:05:16 -0400 Subject: [PATCH] Configure Sentry to not send django.security.DisallowedHost errors --- ocdstoucan/settings.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ocdstoucan/settings.py b/ocdstoucan/settings.py index 19b6638..b2f07be 100644 --- a/ocdstoucan/settings.py +++ b/ocdstoucan/settings.py @@ -15,6 +15,7 @@ import sentry_sdk from django.utils.translation import gettext_lazy as _ from sentry_sdk.integrations.django import DjangoIntegration +from sentry_sdk.integrations.logging import ignore_logger from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration # Build paths inside the project like this: os.path.join(BASE_DIR, ...) @@ -140,6 +141,7 @@ ('es', _('Spanish')), ] +# https://docs.djangoproject.com/en/2.2/topics/logging/#django-security LOGGING = { 'version': 1, 'disable_existing_loggers': False, @@ -160,6 +162,8 @@ OCDS_TOUCAN_MAXFILESIZE = os.getenv('OCDS_TOUCAN_MAXFILESIZE', 10000000) # in bytes if os.getenv('SENTRY_DSN') is not None: + # https://docs.sentry.io/platforms/python/logging/#ignoring-a-logger + ignore_logger('django.security.DisallowedHost') sentry_sdk.init( dsn=os.getenv('SENTRY_DSN'), integrations=[DjangoIntegration(), SqlalchemyIntegration()]