Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

New style middleware#710

Closed
mhindery wants to merge 6 commits intocensus-instrumentation:masterfrom
mhindery:new-style-middleware
Closed

New style middleware#710
mhindery wants to merge 6 commits intocensus-instrumentation:masterfrom
mhindery:new-style-middleware

Conversation

@mhindery
Copy link
Copy Markdown
Contributor

@mhindery mhindery commented Jul 3, 2019

Since old Django versions are not supported anymore (#694), move the middleware to the new style (Django docs on it). This simplifies the code somewhat, since variables are now in one scope of the __call__ method, and there's less of the util functions required which were there to access these variables previously across process_request / process_view / process_request via the thread local context.

I've made the set_django_attributes method public one, as it is useful for people to have the option to easily set their own custom properties apart from the ones used by default.

@timgraham @reyang

@mhindery mhindery requested review from a team, c24t, reyang and songy23 as code owners July 3, 2019 07:28
@timgraham
Copy link
Copy Markdown
Contributor

Old-style middleware are deprecated but supported in Django 1.11 (if using the old MIDDLEWARE_CLASSES setting rather than the new MIDDLEWARE setting). I would delay this change until Django 1.11 end of life. Typically when the next Django LTS is released (Django 2.2 in December 2019), then it's a good time to remove support for older versions of Django.

@reyang
Copy link
Copy Markdown
Contributor

reyang commented Jul 10, 2019

@mhindery I'm closing the PR based on what @timgraham mentioned. Please reopen it once Django 1.11 reached end of life. Thanks.

@reyang reyang closed this Jul 10, 2019
@mhindery
Copy link
Copy Markdown
Contributor Author

I would like to pick this up again. However, it looks to be better at this point to invest in an opentelemetry implementation as that is the successor of the project. There does not seem to be a Django implementation available yet (looking at https://opentelemetry-python.readthedocs.io/en/stable/index.html) Would the project be open to that, if so I would be willing to have a look at that?

@lzchen
Copy link
Copy Markdown
Contributor

lzchen commented Apr 13, 2020

@mhindery
Yes there is not Django integration yet for OpenTelemetry. Feel free to contribute to the OT-python repo! We already have a flask integration leveraging the wsgi integration so you can refer to those.

@mhindery
Copy link
Copy Markdown
Contributor Author

I've started an PR on open-telemetry/opentelemetry-python#571, so I won't develop this one any further.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants