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

Find django spans in the stack #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions opentracing_utils/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

import opentracing

try:
from django.http import HttpRequest
HAVE_DJANGO = True
except ImportError:
HAVE_DJANGO = False

from opentracing import child_of, follows_from
from opentracing.ext import tags as opentracing_tags

Expand Down Expand Up @@ -73,6 +79,9 @@ def inspect_span_from_stack(depth=100):
break

for k, v in frame.f_locals.items():
if HAVE_DJANGO:
if isinstance(v, HttpRequest) and hasattr(v, "current_span"):
span = v.current_span
if isinstance(v, opentracing.Span):
span = v

Expand Down