Skip to content
Merged
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
11 changes: 10 additions & 1 deletion sentry_sdk/integrations/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
from sentry_sdk._types import ExcInfo


def get_name(coro):
# type: (Any) -> str
return (
getattr(coro, "__qualname__", None)
or getattr(coro, "__name__", None)
or "coroutine without __name__"
)


def patch_asyncio():
# type: () -> None
orig_task_factory = None
Expand All @@ -37,7 +46,7 @@ async def _coro_creating_hub_and_span():
result = None

with hub:
with hub.start_span(op=OP.FUNCTION, description=coro.__qualname__):
with hub.start_span(op=OP.FUNCTION, description=get_name(coro)):
try:
result = await coro
except Exception:
Expand Down