Skip to content

Commit 72c1ad8

Browse files
committed
Fixed breadcrumbs in asyncpg
1 parent d2567c9 commit 72c1ad8

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

sentry_sdk/integrations/asyncpg.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,23 +168,29 @@ async def _inner(*args: Any, **kwargs: Any) -> T:
168168
name="connect",
169169
origin=AsyncPGIntegration.origin,
170170
) as span:
171-
span.set_data(SPANDATA.DB_SYSTEM, "postgresql")
171+
span_data = {
172+
SPANDATA.DB_SYSTEM: "postgresql",
173+
SPANDATA.DB_NAME: database,
174+
SPANDATA.DB_USER: user,
175+
}
172176
addr = kwargs.get("addr")
173177
if addr:
174178
try:
175-
span.set_data(SPANDATA.SERVER_ADDRESS, addr[0])
176-
span.set_data(SPANDATA.SERVER_PORT, addr[1])
179+
span_data[SPANDATA.SERVER_ADDRESS] = addr[0]
180+
span_data[SPANDATA.SERVER_PORT] = addr[1]
177181
except IndexError:
178182
pass
179-
span.set_data(SPANDATA.DB_NAME, database)
180-
span.set_data(SPANDATA.DB_USER, user)
183+
184+
for k, v in span_data.items():
185+
span.set_data(k, v)
181186

182187
with capture_internal_exceptions():
183188
sentry_sdk.add_breadcrumb(
184-
message="connect",
185-
category="query",
186-
data=span._data,
189+
message="connect",
190+
category="query",
191+
data=span_data,
187192
)
193+
188194
res = await f(*args, **kwargs)
189195

190196
return res

0 commit comments

Comments
 (0)