Skip to content

Commit

Permalink
ext/django: accept middlewares declared as tuples (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
nightmared committed Aug 5, 2020
1 parent 81025e1 commit 2e70088
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ def _instrument(self, **kwargs):
# https://docs.djangoproject.com/en/3.0/ref/middleware/#middleware-ordering

settings_middleware = getattr(settings, "MIDDLEWARE", [])
settings_middleware.append(self._opentelemetry_middleware)
# Django allows to specify middlewares as a tuple, so we convert this tuple to a
# list, otherwise we wouldn't be able to call append/remove
if isinstance(settings_middleware, tuple):
settings_middleware = list(settings_middleware)

settings_middleware.append(self._opentelemetry_middleware)
setattr(settings, "MIDDLEWARE", settings_middleware)

def _uninstrument(self, **kwargs):
Expand Down

0 comments on commit 2e70088

Please sign in to comment.