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

Use url.rule instead of request.endpoint for span name flask instrumentation #1260

Merged
merged 5 commits into from
Oct 21, 2020
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _before_request():
return

environ = flask.request.environ
span_name = flask.request.endpoint or otel_wsgi.get_default_span_name(
span_name = flask.request.url_rule.rule or otel_wsgi.get_default_span_name(
Copy link
Contributor

Choose a reason for hiding this comment

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

Not familiar enough with flask. Is url_rule always available? What if the rule is not defined and the request is a 404?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not always available. If it's not, we default to the wsgi implementation which is HTTP +

Copy link
Contributor

Choose a reason for hiding this comment

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

Would this raise attribute error if request.url_rule is not always present? or is url_rule always present but rule can be None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a try catch for attribute error in my latest commit.

environ
)
token = context.attach(
Expand Down