Django Middleware and ASGI
See original GitHub issueI read that middleware was working last March per https://github.com/elastic/apm-agent-python/issues/737#issuecomment-597288157 so I have been investigating a transition from WSGI to ASGI.
I am hitting this problem:
Traceback (most recent call last):
File "/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/django/utils/deprecation.py", line 116, in __call__
response = self.process_response(request, response)
File "/elasticapm/contrib/django/middleware/__init__.py", line 114, in process_response_wrapper
response = wrapped(*args, **kwargs)
File "/wagtail/contrib/redirects/middleware.py", line 37, in process_response
if response.status_code != 404:
AttributeError: 'coroutine' object has no attribute 'status_code'
Relevant packages per the linked issue comment
Python 3.7.10
elastic-apm==6.0.0
asgiref==3.3.1
Django==3.1.6
Any tips?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to deploy with ASGI - Django documentation
To apply ASGI middleware, or to embed Django in another ASGI application, you can wrap Django's application object in the asgi.py file. For...
Read more >Django 3.0 + Channels + ASGI + TokenAuthMiddleware
The problem is that you can't access synchronous code from an asynchronous context. Here is a TokenAuthMiddleware for Django 3.0:
Read more >OpenTelemetry ASGI Instrumentation
This library provides a ASGI middleware that can be used on any ASGI framework (such as Django, Starlette, FastAPI or Quart) to track...
Read more >feat: support Django asgi middleware by daniel-sanche · Pull ...
This PR updates our old deprecated MiddlewareMixin Django middleware to use the current best practices, which fixes a crashing bug when using modern...
Read more >A Guide to ASGI in Django 3.0 and its Performance - Arunrocks
If you have a component that can play both roles, then you have created a “middleware” or an intermediate layer in this pipeline....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@thenewguy
ELASTIC_APM_INSTRUMENT_DJANGO_MIDDLEWARE
doesn’t prevent installation of our middleware, but instrumentation of all other middleware. I suspected that there could be an issue with our middleware instrumentation, but that turned out to be not the case.After removing elasticapm from installed apps it seems like this isn’t an elasticapm problem and it was just in the traceback.
Should there be an issue for
export ELASTIC_APM_INSTRUMENT_DJANGO_MIDDLEWARE=False
not preventing the middleware from being installed?