From 7a3f0e3505b579fcf5b3cf62f103c4d81c019cda Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Thu, 23 Apr 2020 15:49:48 -0600 Subject: [PATCH] Adding comment regarding middleware ordering Co-authored-by: Mathieu Hinderyckx --- .../src/opentelemetry/ext/django/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ext/opentelemetry-ext-django/src/opentelemetry/ext/django/__init__.py b/ext/opentelemetry-ext-django/src/opentelemetry/ext/django/__init__.py index cdb0cb88e14..85c7d96208f 100644 --- a/ext/opentelemetry-ext-django/src/opentelemetry/ext/django/__init__.py +++ b/ext/opentelemetry-ext-django/src/opentelemetry/ext/django/__init__.py @@ -67,6 +67,12 @@ def _instrument(self, **kwargs): ): return + # This can not be solved, but is an inherent problem of this approach: + # the order of middleware entries matters, and here you have no control + # on that: + # https://docs.djangoproject.com/en/3.0/topics/http/middleware/#activating-middleware + # https://docs.djangoproject.com/en/3.0/ref/middleware/#middleware-ordering + settings_middleware = getattr(settings, self._middleware_setting, []) settings_middleware.append(self._opentelemetry_middleware)