Skip to content

Commit ad3bde9

Browse files
authored
Fix __qualname__ missing attribute in asyncio integration (#2105)
1 parent fbd7d1a commit ad3bde9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

sentry_sdk/integrations/asyncio.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
from sentry_sdk._types import ExcInfo
2222

2323

24+
def get_name(coro):
25+
# type: (Any) -> str
26+
return (
27+
getattr(coro, "__qualname__", None)
28+
or getattr(coro, "__name__", None)
29+
or "coroutine without __name__"
30+
)
31+
32+
2433
def patch_asyncio():
2534
# type: () -> None
2635
orig_task_factory = None
@@ -37,7 +46,7 @@ async def _coro_creating_hub_and_span():
3746
result = None
3847

3948
with hub:
40-
with hub.start_span(op=OP.FUNCTION, description=coro.__qualname__):
49+
with hub.start_span(op=OP.FUNCTION, description=get_name(coro)):
4150
try:
4251
result = await coro
4352
except Exception:

0 commit comments

Comments
 (0)