From 91d65e033eccc8e13df3b4ac53007623f6d70678 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 21 Jan 2022 18:40:32 +0000 Subject: [PATCH] Fix Django 1.9 issue preventing use of MIDDLEWARE_CLASSES (#870) * Update CHANGELOG.md * Fix Django 1.9 issue preventing use of MIDDLEWARE_CLASSES Co-authored-by: Srikanth Chekuri --- CHANGELOG.md | 1 + .../src/opentelemetry/instrumentation/django/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90b79f1ebe..c093063d83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `opentelemetry-instrumentation-asgi` ASGI: Conditionally create SERVER spans ([#843](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/843)) +- `opentelemetry-instrumentation-django` Django: fix issue preventing detection of MIDDLEWARE_CLASSES ## [1.8.0-0.27b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.8.0-0.27b0) - 2021-12-17 diff --git a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py index 46ee710640..d5e1f07279 100644 --- a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py @@ -105,7 +105,7 @@ def _get_django_middleware_setting() -> str: # In Django versions 1.x, setting MIDDLEWARE_CLASSES can be used as a legacy # alternative to MIDDLEWARE. This is the case when `settings.MIDDLEWARE` has # its default value (`None`). - if not DJANGO_2_0 and getattr(settings, "MIDDLEWARE", []) is None: + if not DJANGO_2_0 and getattr(settings, "MIDDLEWARE", None) is None: return "MIDDLEWARE_CLASSES" return "MIDDLEWARE"