Skip to content

Commit 9c77f53

Browse files
committed
Change get_default_span_details
1 parent ba9cb50 commit 9c77f53

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/asgi_monitor/integrations/litestar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434

3535
def _get_default_span_details(scope: Scope) -> tuple[str, dict[str, Any]]:
36-
route_handler_fn_name = scope["route_handler"].handler_name
37-
return route_handler_fn_name, {SpanAttributes.HTTP_ROUTE: route_handler_fn_name}
36+
method, path = scope["method"], scope["path"]
37+
return f"{method} {path}", {SpanAttributes.HTTP_ROUTE: path}
3838

3939

4040
@dataclass(slots=True, frozen=True)

src/asgi_monitor/integrations/starlette.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def _get_route_details(scope: Scope) -> str | None:
4040
match, _ = starlette_route.matches(scope)
4141
if match == Match.FULL:
4242
route = starlette_route.path
43-
elif match == Match.PARTIAL:
43+
break
44+
if match == Match.PARTIAL:
4445
route = starlette_route.path
4546
return route
4647

tests/integration/litestar/test_middlewares.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def test_tracing() -> None:
5555
"http.method": "GET",
5656
"http.server_name": "testserver.local",
5757
"http.user_agent": "testclient",
58-
"http.route": "index",
58+
"http.route": "/",
5959
"http.status_code": 200,
6060
"net.peer.ip": "testclient",
6161
"net.peer.port": 50000,

0 commit comments

Comments
 (0)