Skip to content

Commit

Permalink
fix: provide ASGI support with Django
Browse files Browse the repository at this point in the history
Signed-off-by: Varsha GS <varsha.gs@ibm.com>
  • Loading branch information
GSVarsha committed Oct 24, 2024
1 parent aaa03d4 commit 86d15b5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/instana/instrumentation/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# (c) Copyright Instana Inc. 2018


import os
import sys

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

def process_request(self, request):
try:
env = request.environ
env = request.META

ctx = tracer.extract(ot.Format.HTTP_HEADERS, env)
request.iscope = tracer.start_active_span('django', child_of=ctx)
Expand Down Expand Up @@ -92,7 +91,7 @@ def process_response(self, request, response):
except Exception:
logger.debug("Instana middleware @ process_response", exc_info=True)
finally:
if request.iscope is not None:
if hasattr(request, "iscope") and request.iscope:
request.iscope.close()
request.iscope = None
return response
Expand Down

0 comments on commit 86d15b5

Please sign in to comment.