Skip to content
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
18 changes: 17 additions & 1 deletion sentry_sdk/integrations/asyncpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def setup_once() -> None:
asyncpg.Connection.prepare = _wrap_connection_method(asyncpg.Connection.prepare)
Comment thread
alexander-alderman-webb marked this conversation as resolved.

BaseCursor._bind_exec = _wrap_cursor_method(BaseCursor._bind_exec)
BaseCursor._bind = _wrap_cursor_method(BaseCursor._bind)
BaseCursor._exec = _wrap_cursor_method(BaseCursor._exec)

asyncpg.connect_utils._connect_addr = _wrap_connect_addr(
Expand Down Expand Up @@ -146,8 +145,17 @@ async def _inner(*args: "Any", **kwargs: "Any") -> "T":
params_list = args[2] if len(args) > 2 else None
with _record(None, query, params_list, executemany=executemany) as span:
_set_db_data(span, args[0])

res = await f(*args, **kwargs)

if isinstance(span, StreamedSpan):
with capture_internal_exceptions():
add_query_source(span)

if not isinstance(span, StreamedSpan):
with capture_internal_exceptions():
add_query_source(span)

return res

return _inner
Expand All @@ -174,6 +182,14 @@ async def _inner(*args: "Any", **kwargs: "Any") -> "T":
_set_db_data(span, cursor._connection)
res = await f(*args, **kwargs)

if isinstance(span, StreamedSpan):
with capture_internal_exceptions():
add_query_source(span)

if not isinstance(span, StreamedSpan):
with capture_internal_exceptions():
add_query_source(span)

return res

return _inner
Expand Down
Loading
Loading