-
Notifications
You must be signed in to change notification settings - Fork 811
Closed
Labels
Description
Hi,
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'