@@ -692,54 +692,6 @@ async def test_async_crumb_capture(
692692 capture_events ,
693693 server_port ,
694694 send_default_pii ,
695- ):
696- sentry_init (
697- integrations = [PyreqwestIntegration ()],
698- send_default_pii = send_default_pii ,
699- )
700-
701- url = f"http://localhost:{ server_port } /hello?q=test#frag"
702-
703- events = capture_events ()
704-
705- # Ensure the isolation scope contextvar is set before pyreqwest spawns
706- # its middleware on a separate asyncio Task. Without this, the child task
707- # lazily creates its own isolation scope, and breadcrumbs added there
708- # don't propagate back to this task's context.
709- sentry_sdk .get_isolation_scope ()
710-
711- with sentry_sdk .start_transaction ():
712- async with ClientBuilder ().build () as client :
713- response = await client .get (url ).build ().send ()
714- assert response .status == 200
715-
716- capture_message ("Testing!" )
717-
718- (event ,) = events
719-
720- crumb = event ["breadcrumbs" ]["values" ][0 ]
721- assert crumb ["type" ] == "http"
722- assert crumb ["category" ] == "httplib"
723-
724- expected = {
725- SPANDATA .HTTP_METHOD : "GET" ,
726- SPANDATA .HTTP_STATUS_CODE : 200 ,
727- }
728- if send_default_pii :
729- expected ["url" ] = f"http://localhost:{ server_port } /hello"
730- expected [SPANDATA .HTTP_QUERY ] = "q=test"
731- expected [SPANDATA .HTTP_FRAGMENT ] = "frag"
732-
733- assert crumb ["data" ] == ApproxDict (expected )
734-
735-
736- @pytest .mark .asyncio
737- @pytest .mark .parametrize ("send_default_pii" , [True , False ])
738- async def test_async_crumb_capture_span_streaming (
739- sentry_init ,
740- capture_events ,
741- server_port ,
742- send_default_pii ,
743695):
744696 sentry_init (
745697 integrations = [PyreqwestIntegration ()],
@@ -801,57 +753,6 @@ def test_crumb_capture_client_error(
801753
802754 events = capture_events ()
803755
804- with sentry_sdk .start_transaction ():
805- client = SyncClientBuilder ().build ()
806- response = client .get (url ).build ().send ()
807- assert response .status == status_code
808-
809- capture_message ("Testing!" )
810-
811- (event ,) = events
812-
813- crumb = event ["breadcrumbs" ]["values" ][0 ]
814- assert crumb ["type" ] == "http"
815- assert crumb ["category" ] == "httplib"
816-
817- if level is None :
818- assert "level" not in crumb
819- else :
820- assert crumb ["level" ] == level
821-
822- assert crumb ["data" ] == ApproxDict (
823- {
824- SPANDATA .HTTP_METHOD : "GET" ,
825- SPANDATA .HTTP_STATUS_CODE : status_code ,
826- }
827- )
828-
829-
830- @pytest .mark .parametrize (
831- "status_code,level" ,
832- [
833- (200 , None ),
834- (301 , None ),
835- (403 , "warning" ),
836- (405 , "warning" ),
837- (500 , "error" ),
838- ],
839- )
840- def test_crumb_capture_client_error_span_streaming (
841- sentry_init ,
842- capture_events ,
843- server_port ,
844- status_code ,
845- level ,
846- ):
847- sentry_init (
848- integrations = [PyreqwestIntegration ()],
849- )
850-
851- url = f"http://localhost:{ server_port } /status/{ status_code } "
852-
853- events = capture_events ()
854-
855756 with sentry_sdk .traces .start_span (name = "segment" ):
856757 client = SyncClientBuilder ().build ()
857758 response = client .get (url ).build ().send ()
@@ -955,7 +856,7 @@ def test_crumb_capture_client_error_span_streaming(
955856 ),
956857 ],
957858)
958- def test_url_query_data_collection_span_streaming_sync (
859+ def test_url_query_data_collection_sync (
959860 sentry_init ,
960861 capture_items ,
961862 server_port ,
@@ -1066,7 +967,7 @@ def test_url_query_data_collection_span_streaming_sync(
1066967 ),
1067968 ],
1068969)
1069- async def test_url_query_data_collection_span_streaming_async (
970+ async def test_url_query_data_collection_async (
1070971 sentry_init ,
1071972 capture_items ,
1072973 server_port ,
@@ -1125,7 +1026,7 @@ async def test_url_query_data_collection_span_streaming_async(
11251026 ),
11261027 ],
11271028)
1128- def test_url_full_reassembly_span_streaming_sync (
1029+ def test_url_full_reassembly_sync (
11291030 sentry_init ,
11301031 capture_items ,
11311032 server_port ,
@@ -1183,7 +1084,7 @@ def test_url_full_reassembly_span_streaming_sync(
11831084 ),
11841085 ],
11851086)
1186- async def test_url_full_reassembly_span_streaming_async (
1087+ async def test_url_full_reassembly_async (
11871088 sentry_init ,
11881089 capture_items ,
11891090 server_port ,
@@ -1243,7 +1144,7 @@ async def test_url_full_reassembly_span_streaming_async(
12431144 ),
12441145 ],
12451146)
1246- def test_url_query_params_off_keeps_bare_url_span_streaming_sync (
1147+ def test_url_query_params_off_keeps_bare_url_sync (
12471148 sentry_init ,
12481149 capture_items ,
12491150 server_port ,
@@ -1311,7 +1212,7 @@ def test_url_query_params_off_keeps_bare_url_span_streaming_sync(
13111212 ),
13121213 ],
13131214)
1314- async def test_url_query_params_off_keeps_bare_url_span_streaming_async (
1215+ async def test_url_query_params_off_keeps_bare_url_async (
13151216 sentry_init ,
13161217 capture_items ,
13171218 server_port ,
@@ -1488,142 +1389,8 @@ async def test_crumb_url_query_data_collection_async(
14881389 assert crumb ["data" ][SPANDATA .HTTP_FRAGMENT ] == "frag"
14891390
14901391
1491- @pytest .mark .parametrize (
1492- "init_kwargs, expected_query" ,
1493- [
1494- pytest .param (
1495- {"_experiments" : {"data_collection" : {}}},
1496- "toy=tennisball&color=red&auth=%5BFiltered%5D" ,
1497- id = "data_collection_denylist_default" ,
1498- ),
1499- pytest .param (
1500- {
1501- "_experiments" : {
1502- "data_collection" : {
1503- "url_query_params" : {"mode" : "allowlist" , "terms" : ["toy" ]}
1504- }
1505- }
1506- },
1507- "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D" ,
1508- id = "data_collection_allowlist" ,
1509- ),
1510- pytest .param (
1511- {
1512- "_experiments" : {
1513- "data_collection" : {"url_query_params" : {"mode" : "off" }}
1514- }
1515- },
1516- "" ,
1517- id = "data_collection_off" ,
1518- ),
1519- ],
1520- )
1521- def test_crumb_url_query_data_collection_legacy_sync (
1522- sentry_init ,
1523- capture_events ,
1524- server_port ,
1525- init_kwargs ,
1526- expected_query ,
1527- ):
1528- """
1529- Legacy (non span streaming) breadcrumbs report the bare URL, but the query
1530- is still filtered according to the data collection configuration. Remove
1531- when we've dropped transaction support and have fully migrated to span
1532- streaming.
1533- """
1534- sentry_init (integrations = [PyreqwestIntegration ()], ** init_kwargs )
1535-
1536- base_url = f"http://localhost:{ server_port } /hello"
1537- url = f"{ base_url } ?toy=tennisball&color=red&auth=secret#frag"
1538-
1539- events = capture_events ()
1540-
1541- client = SyncClientBuilder ().build ()
1542- response = client .get (url ).build ().send ()
1543- assert response .status == 200
1544-
1545- capture_message ("Testing!" )
1546-
1547- (event ,) = events
1548-
1549- crumb = event ["breadcrumbs" ]["values" ][0 ]
1550-
1551- assert crumb ["data" ]["url" ] == base_url
1552- assert crumb ["data" ][SPANDATA .HTTP_QUERY ] == expected_query
1553- assert crumb ["data" ][SPANDATA .HTTP_FRAGMENT ] == "frag"
1554-
1555-
1556- @pytest .mark .asyncio
1557- @pytest .mark .parametrize (
1558- "init_kwargs, expected_query" ,
1559- [
1560- pytest .param (
1561- {"_experiments" : {"data_collection" : {}}},
1562- "toy=tennisball&color=red&auth=%5BFiltered%5D" ,
1563- id = "data_collection_denylist_default" ,
1564- ),
1565- pytest .param (
1566- {
1567- "_experiments" : {
1568- "data_collection" : {
1569- "url_query_params" : {"mode" : "allowlist" , "terms" : ["toy" ]}
1570- }
1571- }
1572- },
1573- "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D" ,
1574- id = "data_collection_allowlist" ,
1575- ),
1576- pytest .param (
1577- {
1578- "_experiments" : {
1579- "data_collection" : {"url_query_params" : {"mode" : "off" }}
1580- }
1581- },
1582- "" ,
1583- id = "data_collection_off" ,
1584- ),
1585- ],
1586- )
1587- async def test_crumb_url_query_data_collection_legacy_async (
1588- sentry_init ,
1589- capture_events ,
1590- server_port ,
1591- init_kwargs ,
1592- expected_query ,
1593- ):
1594- """
1595- Legacy (non span streaming) breadcrumbs report the bare URL, but the query
1596- is still filtered according to the data collection configuration. Remove
1597- when we've dropped transaction support and have fully migrated to span
1598- streaming.
1599- """
1600- sentry_init (integrations = [PyreqwestIntegration ()], ** init_kwargs )
1601-
1602- base_url = f"http://localhost:{ server_port } /hello"
1603- url = f"{ base_url } ?toy=tennisball&color=red&auth=secret#frag"
1604-
1605- events = capture_events ()
1606-
1607- sentry_sdk .get_isolation_scope ()
1608-
1609- with sentry_sdk .start_transaction ():
1610- async with ClientBuilder ().build () as client :
1611- response = await client .get (url ).build ().send ()
1612- assert response .status == 200
1613-
1614- capture_message ("Testing!" )
1615-
1616- event = next (e for e in events if e .get ("breadcrumbs" ))
1617-
1618- crumb = event ["breadcrumbs" ]["values" ][0 ]
1619-
1620- assert crumb ["data" ]["url" ] == base_url
1621- assert crumb ["data" ][SPANDATA .HTTP_QUERY ] == expected_query
1622- assert crumb ["data" ][SPANDATA .HTTP_FRAGMENT ] == "frag"
1623-
1624-
16251392@pytest .mark .tests_internal_exceptions
1626- def test_omit_url_data_if_parsing_fails_span_streaming (
1393+ def test_omit_url_data_if_parsing_fails_data_collection (
16271394 sentry_init ,
16281395 capture_events ,
16291396 capture_items ,
0 commit comments