Skip to content

feat(django): Instrument views as spans #787

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

Merged
merged 13 commits into from
Aug 13, 2020

Conversation

untitaker
Copy link
Member

@untitaker untitaker commented Aug 12, 2020

This adds spans around URL resolving and the view itself.

@untitaker untitaker requested a review from rhcarvalho August 12, 2020 18:16
@untitaker untitaker changed the title feat: Instrument views as spans feat(django): Instrument views as spans Aug 12, 2020
@@ -118,7 +118,7 @@ class Address(Base):
assert (
render_span_tree(event)
== """\
- op=None: description=None
- op=None: description='None'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why op is None and description is 'None'? Other ops below have quotes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm maybe None => JSON's null, while the description will always be a string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah that's an unfortunate side-effect. Will switch to json.dumps as representation method

@@ -334,7 +334,7 @@ def inner(event):
by_parent.setdefault(span["parent_span_id"], []).append(span)

def render_span(span):
yield "- op={!r}: description={!r}".format(
yield "- op='{}': description='{}'".format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the motivation to change this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It caused incompatibilities between Python 2 and 3 when rendering unicode strings.

if integration is None or not integration.middleware_spans:
return old_resolve(self, path)

with hub.start_span(op="django.urls.resolve"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is of much use. If all the resolver does is call the view, isn't it going to be very similar in duration to the django.view span?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah let's remove it. resolver is probably fast enough, usually

@untitaker untitaker merged commit 193f591 into master Aug 13, 2020
@untitaker untitaker deleted the feat/django-3-view-instrumentation branch August 13, 2020 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants