Skip to content

Commit

Permalink
re-add a name fallback
Browse files Browse the repository at this point in the history
This was removed in open-telemetry#1759.
  • Loading branch information
muncus committed Jun 21, 2023
1 parent db85f97 commit 0ea524b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ def _get_span_name(request):

if hasattr(match, "route") and match.route:
return f"{request.method} {match.route}"

if hasattr(match, "url_name") and match.url_name:
return f"{request.method} {match.url_name}"

return request.method

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@
from django.urls import path
else:
from django.conf.urls import url as re_path

def path(p, *args, **kwargs):
return re_path(r"^%s$" % p, *args, **kwargs)
return re_path(r"^%s$" % p, *args, **kwargs)


urlpatterns = [
re_path(r"^traced/", traced),
Expand Down Expand Up @@ -217,7 +219,7 @@ def test_empty_path(self):

span = spans[0]

self.assertEqual(span.name, "empty")
self.assertEqual(span.name, "GET empty")

def test_traced_post(self):
Client().post("/traced/")
Expand Down

0 comments on commit 0ea524b

Please sign in to comment.