From 92d86c75fd1629db0f88512506d1e84a36007457 Mon Sep 17 00:00:00 2001 From: Samuel Paccoud - FUN MOOC Date: Thu, 29 Nov 2018 16:12:25 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(sentry)=20fix=20logging=20environm?= =?UTF-8?q?ent=20in=20Sentry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous implementation was not working because the ENVIRONMENT setting was redefined after the LOGGING setting had already been set to with "production" as the environment. I propose to directly override the value of the environment in the LOGGING setting. --- config/cms/docker_run_development.py | 3 ++- config/cms/docker_run_feature.py | 2 +- config/cms/docker_run_preprod.py | 2 +- config/cms/docker_run_production.py | 3 +-- config/cms/docker_run_staging.py | 2 +- config/lms/docker_run_development.py | 3 ++- config/lms/docker_run_feature.py | 2 +- config/lms/docker_run_preprod.py | 2 +- config/lms/docker_run_production.py | 3 +-- config/lms/docker_run_staging.py | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config/cms/docker_run_development.py b/config/cms/docker_run_development.py index b60ab0c8..3dd5ff6d 100644 --- a/config/cms/docker_run_development.py +++ b/config/cms/docker_run_development.py @@ -7,7 +7,8 @@ # Load custom configuration parameters from yaml files config = Configuration(os.path.dirname(__file__)) -ENVIRONMENT = "development" +LOGGING["handlers"]["sentry"]["environment"] = "development" + DEBUG = True REQUIRE_DEBUG = True diff --git a/config/cms/docker_run_feature.py b/config/cms/docker_run_feature.py index 9da2b330..2595eb26 100644 --- a/config/cms/docker_run_feature.py +++ b/config/cms/docker_run_feature.py @@ -7,7 +7,7 @@ # Load custom configuration parameters from yaml files config = Configuration(os.path.dirname(__file__)) -ENVIRONMENT = "feature" +LOGGING["handlers"]["sentry"]["environment"] = "feature" EMAIL_BACKEND = config( "EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend" diff --git a/config/cms/docker_run_preprod.py b/config/cms/docker_run_preprod.py index 70d69054..8748dc70 100644 --- a/config/cms/docker_run_preprod.py +++ b/config/cms/docker_run_preprod.py @@ -7,7 +7,7 @@ # Load custom configuration parameters from yaml files config = Configuration(os.path.dirname(__file__)) -ENVIRONMENT = "preprod" +LOGGING["handlers"]["sentry"]["environment"] = "preprod" EMAIL_BACKEND = config( "EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend" diff --git a/config/cms/docker_run_production.py b/config/cms/docker_run_production.py index 1c0e4a35..59512613 100644 --- a/config/cms/docker_run_production.py +++ b/config/cms/docker_run_production.py @@ -26,7 +26,6 @@ ############### ALWAYS THE SAME ################################ -ENVIRONMENT = "production" RELEASE = config("RELEASE", default=None) DEBUG = False @@ -321,7 +320,7 @@ "class": "raven.handlers.logging.SentryHandler", "dsn": SENTRY_DSN, "level": "ERROR", - "environment": ENVIRONMENT, + "environment": "production", "release": RELEASE, } diff --git a/config/cms/docker_run_staging.py b/config/cms/docker_run_staging.py index cebb1434..e799579c 100644 --- a/config/cms/docker_run_staging.py +++ b/config/cms/docker_run_staging.py @@ -7,7 +7,7 @@ # Load custom configuration parameters from yaml files config = Configuration(os.path.dirname(__file__)) -ENVIRONMENT = "staging" +LOGGING["handlers"]["sentry"]["environment"] = "staging" EMAIL_BACKEND = config( "EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend" diff --git a/config/lms/docker_run_development.py b/config/lms/docker_run_development.py index 27a5a849..e693a30d 100644 --- a/config/lms/docker_run_development.py +++ b/config/lms/docker_run_development.py @@ -7,7 +7,8 @@ # Load custom configuration parameters from yaml files config = Configuration(os.path.dirname(__file__)) -ENVIRONMENT = "development" +LOGGING["handlers"]["sentry"]["environment"] = "development" + DEBUG = True REQUIRE_DEBUG = True diff --git a/config/lms/docker_run_feature.py b/config/lms/docker_run_feature.py index bbb88e6b..60012814 100644 --- a/config/lms/docker_run_feature.py +++ b/config/lms/docker_run_feature.py @@ -7,7 +7,7 @@ # Load custom configuration parameters from yaml files config = Configuration(os.path.dirname(__file__)) -ENVIRONMENT = "feature" +LOGGING["handlers"]["sentry"]["environment"] = "feature" EMAIL_BACKEND = config( "EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend" diff --git a/config/lms/docker_run_preprod.py b/config/lms/docker_run_preprod.py index ed60aef3..03a831d4 100644 --- a/config/lms/docker_run_preprod.py +++ b/config/lms/docker_run_preprod.py @@ -7,7 +7,7 @@ # Load custom configuration parameters from yaml files config = Configuration(os.path.dirname(__file__)) -ENVIRONMENT = "preprod" +LOGGING["handlers"]["sentry"]["environment"] = "preprod" EMAIL_BACKEND = config( "EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend" diff --git a/config/lms/docker_run_production.py b/config/lms/docker_run_production.py index a33132ac..a5c2e59d 100644 --- a/config/lms/docker_run_production.py +++ b/config/lms/docker_run_production.py @@ -29,7 +29,6 @@ ################################ ALWAYS THE SAME ############################## -ENVIRONMENT = "production" RELEASE = config("RELEASE", default=None) DEBUG = False DEFAULT_TEMPLATE_ENGINE["OPTIONS"]["debug"] = False @@ -432,7 +431,7 @@ "class": "raven.handlers.logging.SentryHandler", "dsn": SENTRY_DSN, "level": "ERROR", - "environment": ENVIRONMENT, + "environment": "production", "release": RELEASE, } diff --git a/config/lms/docker_run_staging.py b/config/lms/docker_run_staging.py index 42304f72..7c878eb2 100644 --- a/config/lms/docker_run_staging.py +++ b/config/lms/docker_run_staging.py @@ -7,7 +7,7 @@ # Load custom configuration parameters from yaml files config = Configuration(os.path.dirname(__file__)) -ENVIRONMENT = "staging" +LOGGING["handlers"]["sentry"]["environment"] = "staging" EMAIL_BACKEND = config( "EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend"