Skip to content

Commit 2c3579b

Browse files
committed
Remove _bind patch as it does not run queries, only prepares the cursor. Update tests
1 parent 141de46 commit 2c3579b

2 files changed

Lines changed: 7 additions & 22 deletions

File tree

sentry_sdk/integrations/asyncpg.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def setup_once() -> None:
5454
asyncpg.Connection.prepare = _wrap_connection_method(asyncpg.Connection.prepare)
5555

5656
BaseCursor._bind_exec = _wrap_cursor_method(BaseCursor._bind_exec)
57-
BaseCursor._bind = _wrap_cursor_method(BaseCursor._bind)
5857
BaseCursor._exec = _wrap_cursor_method(BaseCursor._exec)
5958

6059
asyncpg.connect_utils._connect_addr = _wrap_connect_addr(

tests/integrations/asyncpg/test_asyncpg.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,6 @@ async def test_cursor_manual(sentry_init, capture_events) -> None:
410410
"message": "SELECT * FROM users WHERE dob > $1",
411411
"type": "default",
412412
},
413-
{
414-
"category": "query",
415-
"data": {"db.cursor": mock.ANY},
416-
"message": "SELECT * FROM users WHERE dob > $1",
417-
"type": "default",
418-
},
419413
{"category": "query", "data": {}, "message": "COMMIT;", "type": "default"},
420414
]
421415

@@ -1468,9 +1462,7 @@ async def test_cursor__bind_exec_creates_spans(
14681462

14691463

14701464
@pytest.mark.asyncio
1471-
async def test_cursor__bind_and__exec_methods_create_spans(
1472-
sentry_init, capture_events
1473-
) -> None:
1465+
async def test_cursor__exec_methods_create_spans(sentry_init, capture_events) -> None:
14741466
sentry_init(
14751467
integrations=[AsyncPGIntegration()],
14761468
traces_sample_rate=1.0,
@@ -1491,7 +1483,6 @@ async def test_cursor__bind_and__exec_methods_create_spans(
14911483
)
14921484

14931485
async with conn.transaction():
1494-
# This exercises the `_bind` patch and the `cursor` patch
14951486
cur = await conn.cursor(
14961487
"SELECT * FROM users WHERE dob > $1", datetime.date(1970, 1, 1)
14971488
)
@@ -1503,15 +1494,14 @@ async def test_cursor__bind_and__exec_methods_create_spans(
15031494

15041495
(event,) = events
15051496

1506-
assert len(event["spans"]) == 7
1497+
assert len(event["spans"]) == 6
15071498

15081499
connect_span = event["spans"][0]
15091500
executemany_span = event["spans"][1]
15101501
begin_span = event["spans"][2]
1511-
cursor_creation_and_bind_span = event["spans"][3]
1512-
fetchrow_span_1 = event["spans"][4]
1513-
fetchrow_span_2 = event["spans"][5]
1514-
commit_span = event["spans"][6]
1502+
fetchrow_span_1 = event["spans"][3]
1503+
fetchrow_span_2 = event["spans"][4]
1504+
commit_span = event["spans"][5]
15151505

15161506
assert connect_span["description"] == "connect"
15171507
assert (
@@ -1520,20 +1510,16 @@ async def test_cursor__bind_and__exec_methods_create_spans(
15201510
)
15211511
assert begin_span["description"] == "BEGIN;"
15221512
assert fetchrow_span_1["description"] == "SELECT * FROM users WHERE dob > $1"
1523-
assert (
1524-
cursor_creation_and_bind_span["description"]
1525-
== "SELECT * FROM users WHERE dob > $1"
1526-
)
15271513
assert fetchrow_span_2["description"] == "SELECT * FROM users WHERE dob > $1"
15281514
assert commit_span["description"] == "COMMIT;"
15291515

1530-
for span in (cursor_creation_and_bind_span, fetchrow_span_1, fetchrow_span_2):
1516+
for span in (fetchrow_span_1, fetchrow_span_2):
15311517
assert span["data"]["db.cursor"] is not None
15321518
assert span["data"]["db.system"] == "postgresql"
15331519
assert span["data"]["db.driver.name"] == "asyncpg"
15341520
assert span["origin"] == "auto.db.asyncpg"
15351521
_assert_query_source(
15361522
span,
15371523
False,
1538-
"test_cursor__bind_and__exec_methods_create_spans",
1524+
"test_cursor__exec_methods_create_spans",
15391525
)

0 commit comments

Comments
 (0)