Error in opentelemetry/instrumentation/django/middleware.py related to "wsgi.url_scheme"
See original GitHub issueHi, Appreciate your support. We try to use DjangoInstrumentor by putting it in settings.py as the below,
from opentelemetry.instrumentation.django import DjangoInstrumentor
DjangoInstrumentor().instrument()
Our application uses Django channels and the above code gives us an error. After debugging we found out that the cause of the error is in opentelemetry/instrumentation/django/middleware.py related to “wsgi.url_scheme”. Please check the stacktrace for details.
Any thoughts on how to bypass this issue in both development and production servers ?
My environment: Django version 3.1.2 Python version 3.8 Channels version 2.2.0
Stack trace:
Traceback (most recent call last):
File "/home/omar/workspace/testapp/testapp/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/omar/workspace/testapp/testapp/venv/lib/python3.8/site-packages/django/utils/deprecation.py", line 113, in __call__
response = self.process_request(request)
File "/home/omar/workspace/testapp/testapp/venv/lib/python3.8/site-packages/opentelemetry/instrumentation/django/middleware.py", line 140, in process_request
attributes = collect_request_attributes(environ)
File "/home/omar/workspace/testapp/testapp/venv/lib/python3.8/site-packages/opentelemetry/instrumentation/wsgi/__init__.py", line 122, in collect_request_attributes
result["http.url"] = wsgiref_util.request_uri(environ)
File "/usr/lib/python3.8/wsgiref/util.py", line 72, in request_uri
url = application_uri(environ)
File "/usr/lib/python3.8/wsgiref/util.py", line 52, in application_uri
url = environ['wsgi.url_scheme']+'://'
KeyError: 'wsgi.url_scheme'
[public ERROR ] Internal Server Error: /
Traceback (most recent call last):
File "/home/omar/workspace/testapp/testapp/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/omar/workspace/testapp/testapp/venv/lib/python3.8/site-packages/django/utils/deprecation.py", line 113, in __call__
response = self.process_request(request)
File "/home/omar/workspace/testapp/testapp/venv/lib/python3.8/site-packages/opentelemetry/instrumentation/django/middleware.py", line 140, in process_request
attributes = collect_request_attributes(environ)
File "/home/omar/workspace/testapp/testapp/venv/lib/python3.8/site-packages/opentelemetry/instrumentation/wsgi/__init__.py", line 122, in collect_request_attributes
result["http.url"] = wsgiref_util.request_uri(environ)
File "/usr/lib/python3.8/wsgiref/util.py", line 72, in request_uri
url = application_uri(environ)
File "/usr/lib/python3.8/wsgiref/util.py", line 52, in application_uri
url = environ['wsgi.url_scheme']+'://'
KeyError: 'wsgi.url_scheme'
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Error in opentelemetry/instrumentation/django/middleware.py ...
Hi, Appreciate your support. ... Our application uses Django channels and the above code gives us an error. ... related to "wsgi.url_scheme". Please ......
Read more >wsgi.py cannot be loaded as Python module Error / No ...
I have restart the project and this issue comes in each time I start using Postgres db, so my guess is that it...
Read more >Debugging Techniques — mod_wsgi 4.9.4 documentation
An alternative to the Python debugger modules which is available is an extension of the WSGI error catching middleware previously described. This is...
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
@OmarEltamasehy, as this issue was automatically closed, I’m pinging you to let you know that Django ASGI support has been added in #391, and released in version
0.25b0
. It requires installingopentelemetry-instrumentation-django
with theasgi
extra.Closed as inactive. Feel free to reopen if this issue needs resolving.