Skip to content

Commit 86d15b5

Browse files
committed
fix: provide ASGI support with Django
Signed-off-by: Varsha GS <[email protected]>
1 parent aaa03d4 commit 86d15b5

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/instana/instrumentation/django/middleware.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# (c) Copyright Instana Inc. 2018
33

44

5-
import os
65
import sys
76

87
import opentracing as ot
@@ -45,7 +44,7 @@ def _extract_custom_headers(self, span, headers, format):
4544

4645
def process_request(self, request):
4746
try:
48-
env = request.environ
47+
env = request.META
4948

5049
ctx = tracer.extract(ot.Format.HTTP_HEADERS, env)
5150
request.iscope = tracer.start_active_span('django', child_of=ctx)
@@ -92,7 +91,7 @@ def process_response(self, request, response):
9291
except Exception:
9392
logger.debug("Instana middleware @ process_response", exc_info=True)
9493
finally:
95-
if request.iscope is not None:
94+
if hasattr(request, "iscope") and request.iscope:
9695
request.iscope.close()
9796
request.iscope = None
9897
return response

0 commit comments

Comments
 (0)