@@ -102,7 +102,7 @@ def _connect_args():
102102async def test_connect (sentry_init , capture_events ) -> None :
103103 sentry_init (
104104 integrations = [AioMySQLIntegration ()],
105- _experiments = {"record_sql_params " : True },
105+ data_collection = {"database_query_data " : True },
106106 )
107107 events = capture_events ()
108108
@@ -123,7 +123,7 @@ async def test_connect(sentry_init, capture_events) -> None:
123123async def test_execute (sentry_init , capture_events ) -> None :
124124 sentry_init (
125125 integrations = [AioMySQLIntegration ()],
126- _experiments = {"record_sql_params " : True },
126+ data_collection = {"database_query_data " : True },
127127 )
128128 events = capture_events ()
129129
@@ -160,13 +160,19 @@ async def test_execute(sentry_init, capture_events) -> None:
160160 },
161161 {
162162 "category" : "query" ,
163- "data" : {},
163+ "data" : {
164+ "db.params" : ["Bob" , "secret_pw" , "datetime.date(1984, 3, 1)" ],
165+ "db.paramstyle" : "format" ,
166+ },
164167 "message" : "INSERT INTO users(name, password, dob) VALUES (%s, %s, %s)" ,
165168 "type" : "default" ,
166169 },
167170 {
168171 "category" : "query" ,
169- "data" : {},
172+ "data" : {
173+ "db.params" : ["Bob" ],
174+ "db.paramstyle" : "format" ,
175+ },
170176 "message" : "SELECT * FROM users WHERE name = %s" ,
171177 "type" : "default" ,
172178 },
@@ -177,7 +183,6 @@ async def test_execute(sentry_init, capture_events) -> None:
177183async def test_execute_many (sentry_init , capture_events ) -> None :
178184 sentry_init (
179185 integrations = [AioMySQLIntegration ()],
180- _experiments = {"record_sql_params" : True },
181186 )
182187 events = capture_events ()
183188
@@ -260,47 +265,6 @@ async def test_execute_many_record_params_with_data_collection_enabled(
260265 ]
261266
262267
263- @pytest .mark .asyncio
264- async def test_execute_many_record_params_with_data_collection_disabled (
265- sentry_init , capture_events
266- ) -> None :
267- sentry_init (
268- integrations = [AioMySQLIntegration (record_params = True )],
269- data_collection = {"database_query_data" : False },
270- )
271- events = capture_events ()
272-
273- conn = await aiomysql .connect (** _connect_args ())
274-
275- async with conn .cursor () as cur :
276- await cur .executemany (
277- "INSERT INTO users(name, password, dob) VALUES (%s, %s, %s)" ,
278- [
279- ("Bob" , "secret_pw" , datetime .date (1984 , 3 , 1 )),
280- ("Alice" , "pw" , datetime .date (1990 , 12 , 25 )),
281- ],
282- )
283-
284- conn .close ()
285-
286- capture_message ("hi" )
287-
288- (event ,) = events
289-
290- for crumb in event ["breadcrumbs" ]["values" ]:
291- del crumb ["timestamp" ]
292-
293- assert event ["breadcrumbs" ]["values" ] == [
294- CRUMBS_CONNECT ,
295- {
296- "category" : "query" ,
297- "data" : {"db.executemany" : True },
298- "message" : "INSERT INTO users(name, password, dob) VALUES (%s, %s, %s)" ,
299- "type" : "default" ,
300- },
301- ]
302-
303-
304268@pytest .mark .asyncio
305269async def test_execute_many_record_params_with_data_collection_default (
306270 sentry_init , capture_events
@@ -354,7 +318,7 @@ async def test_execute_many_non_insert(sentry_init, capture_events) -> None:
354318 """Test executemany with non-INSERT queries (falls back to row-by-row)."""
355319 sentry_init (
356320 integrations = [AioMySQLIntegration ()],
357- _experiments = {"record_sql_params " : True },
321+ data_collection = {"database_query_data " : True },
358322 )
359323 events = capture_events ()
360324
@@ -400,48 +364,7 @@ async def test_execute_many_non_insert(sentry_init, capture_events) -> None:
400364
401365
402366@pytest .mark .asyncio
403- async def test_record_params (sentry_init , capture_events ) -> None :
404- sentry_init (
405- integrations = [AioMySQLIntegration (record_params = True )],
406- _experiments = {"record_sql_params" : True },
407- )
408- events = capture_events ()
409-
410- conn = await aiomysql .connect (** _connect_args ())
411-
412- async with conn .cursor () as cur :
413- await cur .execute (
414- "INSERT INTO users(name, password, dob) VALUES (%s, %s, %s)" ,
415- ("Bob" , "secret_pw" , datetime .date (1984 , 3 , 1 )),
416- )
417-
418- conn .close ()
419-
420- capture_message ("hi" )
421-
422- (event ,) = events
423-
424- for crumb in event ["breadcrumbs" ]["values" ]:
425- del crumb ["timestamp" ]
426-
427- assert event ["breadcrumbs" ]["values" ] == [
428- CRUMBS_CONNECT ,
429- {
430- "category" : "query" ,
431- "data" : {
432- "db.params" : ["Bob" , "secret_pw" , "datetime.date(1984, 3, 1)" ],
433- "db.paramstyle" : "format" ,
434- },
435- "message" : "INSERT INTO users(name, password, dob) VALUES (%s, %s, %s)" ,
436- "type" : "default" ,
437- },
438- ]
439-
440-
441- @pytest .mark .asyncio
442- async def test_execute_record_params_with_data_collection_enabled (
443- sentry_init , capture_events
444- ) -> None :
367+ async def test_execute_record_params (sentry_init , capture_events ) -> None :
445368 sentry_init (
446369 integrations = [AioMySQLIntegration ()],
447370 data_collection = {"database_query_data" : True },
@@ -479,44 +402,6 @@ async def test_execute_record_params_with_data_collection_enabled(
479402 ]
480403
481404
482- @pytest .mark .asyncio
483- async def test_execute_record_params_with_data_collection_disabled (
484- sentry_init , capture_events
485- ) -> None :
486- sentry_init (
487- integrations = [AioMySQLIntegration (record_params = True )],
488- data_collection = {"database_query_data" : False },
489- )
490- events = capture_events ()
491-
492- conn = await aiomysql .connect (** _connect_args ())
493-
494- async with conn .cursor () as cur :
495- await cur .execute (
496- "INSERT INTO users(name, password, dob) VALUES (%s, %s, %s)" ,
497- ("Bob" , "secret_pw" , datetime .date (1984 , 3 , 1 )),
498- )
499-
500- conn .close ()
501-
502- capture_message ("hi" )
503-
504- (event ,) = events
505-
506- for crumb in event ["breadcrumbs" ]["values" ]:
507- del crumb ["timestamp" ]
508-
509- assert event ["breadcrumbs" ]["values" ] == [
510- CRUMBS_CONNECT ,
511- {
512- "category" : "query" ,
513- "data" : {},
514- "message" : "INSERT INTO users(name, password, dob) VALUES (%s, %s, %s)" ,
515- "type" : "default" ,
516- },
517- ]
518-
519-
520405@pytest .mark .asyncio
521406async def test_execute_record_params_with_data_collection_default (
522407 sentry_init , capture_events
@@ -562,7 +447,7 @@ async def test_execute_record_params_with_data_collection_default(
562447async def test_cursor_context_manager (sentry_init , capture_events ) -> None :
563448 sentry_init (
564449 integrations = [AioMySQLIntegration ()],
565- _experiments = {"record_sql_params " : True },
450+ data_collection = {"database_query_data " : True },
566451 )
567452 events = capture_events ()
568453
@@ -604,7 +489,7 @@ async def test_cursor_context_manager(sentry_init, capture_events) -> None:
604489async def test_cursor_async_iteration (sentry_init , capture_events ) -> None :
605490 sentry_init (
606491 integrations = [AioMySQLIntegration ()],
607- _experiments = {"record_sql_params " : True },
492+ data_collection = {"database_query_data " : True },
608493 )
609494 events = capture_events ()
610495
@@ -637,7 +522,7 @@ async def test_cursor_async_iteration(sentry_init, capture_events) -> None:
637522async def test_connection_pool (sentry_init , capture_events ) -> None :
638523 sentry_init (
639524 integrations = [AioMySQLIntegration ()],
640- _experiments = {"record_sql_params " : True },
525+ data_collection = {"database_query_data " : True },
641526 )
642527 events = capture_events ()
643528
0 commit comments