@@ -1137,10 +1137,14 @@ async def handle(_):
11371137
11381138
11391139@pytest .mark .asyncio
1140- async def test_tracing_span_streaming (sentry_init , aiohttp_client , capture_items ):
1140+ @pytest .mark .parametrize ("send_pii" , [True , False ])
1141+ async def test_tracing_span_streaming (
1142+ sentry_init , aiohttp_client , capture_items , send_pii
1143+ ):
11411144 sentry_init (
11421145 integrations = [AioHttpIntegration ()],
11431146 traces_sample_rate = 1.0 ,
1147+ send_default_pii = send_pii ,
11441148 _experiments = {"trace_lifecycle" : "stream" },
11451149 )
11461150
@@ -1184,13 +1188,25 @@ async def hello(request):
11841188
11851189 # Request attributes derived directly from the aiohttp request.
11861190 assert server_span ["attributes" ]["http.request.method" ] == "GET"
1187- # client.address and user.ip_address is gated on send_default_pii (default False), so it must
1188- # not be captured here.
1189- assert "client.address" not in server_span ["attributes" ]
1190- assert "user.ip_address" not in server_span ["attributes" ]
1191- url_full = server_span ["attributes" ]["url.full" ]
1192- assert url_full .startswith ("http://127.0.0.1:" )
1193- assert url_full .endswith ("/" )
1191+
1192+ if send_pii :
1193+ assert "client.address" in server_span ["attributes" ]
1194+ assert "user.ip_address" in server_span ["attributes" ]
1195+
1196+ url_full = server_span ["attributes" ]["url.full" ]
1197+ assert url_full .startswith ("http://127.0.0.1:" )
1198+ assert url_full .endswith ("/" )
1199+
1200+ url_path = server_span ["attributes" ]["url.path" ]
1201+ assert url_path == "/"
1202+ else :
1203+ assert "url.full" not in server_span ["attributes" ]
1204+ assert "url.path" not in server_span ["attributes" ]
1205+ assert "url.query" not in server_span ["attributes" ]
1206+
1207+ assert "client.address" not in server_span ["attributes" ]
1208+ assert "user.ip_address" not in server_span ["attributes" ]
1209+
11941210 # aiohttp's test client always sends a Host header; we assert it propagates
11951211 # into the span attributes via _filter_headers.
11961212 assert "http.request.header.host" in server_span ["attributes" ]
@@ -1280,12 +1296,14 @@ async def hello(request):
12801296
12811297
12821298@pytest .mark .asyncio
1299+ @pytest .mark .parametrize ("send_pii" , [True , False ])
12831300async def test_url_query_attribute_span_streaming (
1284- sentry_init , aiohttp_client , capture_items
1301+ sentry_init , aiohttp_client , capture_items , send_pii
12851302):
12861303 sentry_init (
12871304 integrations = [AioHttpIntegration ()],
12881305 traces_sample_rate = 1.0 ,
1306+ send_default_pii = send_pii ,
12891307 _experiments = {"trace_lifecycle" : "stream" },
12901308 )
12911309
@@ -1306,7 +1324,10 @@ async def hello(request):
13061324 assert len (items ) == 2
13071325 server_segment , client_segment = [item .payload for item in items ]
13081326
1309- assert server_segment ["attributes" ]["url.query" ] == "foo=bar&baz=qux"
1327+ if send_pii :
1328+ assert server_segment ["attributes" ]["url.query" ] == "foo=bar&baz=qux"
1329+ else :
1330+ assert "url.query" not in server_segment ["attributes" ]
13101331
13111332
13121333@pytest .mark .asyncio
@@ -1486,12 +1507,14 @@ async def hello(request):
14861507
14871508
14881509@pytest .mark .asyncio
1510+ @pytest .mark .parametrize ("send_pii" , [True , False ])
14891511async def test_outgoing_client_span_span_streaming (
1490- sentry_init , aiohttp_raw_server , aiohttp_client , capture_items
1512+ sentry_init , aiohttp_raw_server , aiohttp_client , capture_items , send_pii
14911513):
14921514 sentry_init (
14931515 integrations = [AioHttpIntegration ()],
14941516 traces_sample_rate = 1.0 ,
1517+ send_default_pii = send_pii ,
14951518 _experiments = {"trace_lifecycle" : "stream" },
14961519 )
14971520
@@ -1536,14 +1559,19 @@ async def hello(request):
15361559 assert inner_client_span ["attributes" ]["sentry.origin" ] == "auto.http.aiohttp"
15371560 assert inner_client_span ["attributes" ]["http.request.method" ] == "GET"
15381561 assert inner_client_span ["attributes" ]["http.response.status_code" ] == 200
1539- assert inner_client_span ["attributes" ]["url.query" ] == "foo=bar"
15401562 assert inner_client_span ["status" ] == "ok"
15411563
1542- url_full = inner_client_span ["attributes" ]["url.full" ]
1543- # parse_url() splits the URL — url.full is the base URL only, with the
1544- # query string captured separately on url.query.
1545- assert url_full .startswith ("http://127.0.0.1:" )
1546- assert url_full .endswith ("/" )
1564+ if send_pii :
1565+ assert inner_client_span ["attributes" ]["url.query" ] == "foo=bar"
1566+
1567+ url_full = inner_client_span ["attributes" ]["url.full" ]
1568+
1569+ # parse_url() splits the URL — url.full is the base URL only, with the
1570+ # query string captured separately on url.query.
1571+ assert url_full .startswith ("http://127.0.0.1:" )
1572+ assert url_full .endswith ("/" )
1573+
1574+ assert inner_client_span ["attributes" ]["url.path" ] == "/"
15471575
15481576
15491577@pytest .mark .asyncio
0 commit comments