Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: provide ASGI support with Django #655

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading