New style middleware#710
New style middleware#710mhindery wants to merge 6 commits intocensus-instrumentation:masterfrom mhindery:new-style-middleware
Conversation
|
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. |
|
@mhindery I'm closing the PR based on what @timgraham mentioned. Please reopen it once Django 1.11 reached end of life. Thanks. |
|
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? |
|
I've started an PR on open-telemetry/opentelemetry-python#571, so I won't develop this one any further. |
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 acrossprocess_request/process_view/process_requestvia the thread local context.I've made the
set_django_attributesmethod 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