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

Bugfix django instrumentation #1309

Merged
merged 6 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Django instrumentation is now enabled by default but can be disabled by setting `OTEL_PYTHON_DJANGO_INSTRUMENT` to `False` ([#1239](https://github.com/open-telemetry/opentelemetry-python/pull/1239))
- Bugfix use request.path replace request.get_full_path(). It will get correct span name ([#1309](https://github.com/open-telemetry/opentelemetry-python/pull/1309#))
Copy link
Member

@toumorokoshi toumorokoshi Oct 31, 2020

Choose a reason for hiding this comment

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

Typically with changelogs, you should try to have information that's relevant to the user, so mainly behavior. The details aren't really helpful to most.

In this case, it's sufficient to say "span name resolves correctly for paths that also require a query parameter to match".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your suggestion, I will pay attention to it later


## Version 0.14b0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _get_span_name(request):
if getattr(request, "resolver_match"):
match = request.resolver_match
else:
match = resolve(request.get_full_path())
match = resolve(request.path)

if hasattr(match, "route"):
return match.route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def test_exclude_lists(self):
self.assertEqual(len(span_list), 1)

def test_span_name(self):
# test no query_string
Client().get("/span_name/1234/")
span_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(span_list), 1)
Expand All @@ -262,6 +263,22 @@ def test_span_name(self):
else "tests.views.route_span_name",
)

def test_span_name_for_query_string(self):
"""
request not have query string
"""
Client().get("/span_name/1234/?query=test")
span_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(span_list), 1)

span = span_list[0]
self.assertEqual(
span.name,
"^span_name/([0-9]{4})/$"
if DJANGO_2_2
else "tests.views.route_span_name",
)

def test_span_name_404(self):
Client().get("/span_name/1234567890/")
span_list = self.memory_exporter.get_finished_spans()
Expand Down