@@ -828,6 +828,52 @@ async def request_handler(request):
828828 self ._assert_spans ([], 0 )
829829 self ._assert_metrics (0 )
830830
831+ def test_metric_attributes_isolation (self ):
832+ async def success_handler (request ):
833+ assert "traceparent" in request .headers
834+ return aiohttp .web .Response (status = HTTPStatus .OK )
835+
836+ async def timeout_handler (request ):
837+ await asyncio .sleep (60 )
838+ assert "traceparent" in request .headers
839+ return aiohttp .web .Response (status = HTTPStatus .OK )
840+
841+ success_host , success_port = self ._http_request (
842+ trace_config = aiohttp_client .create_trace_config (),
843+ url = "/success" ,
844+ request_handler = success_handler ,
845+ )
846+
847+ timeout_host , timeout_port = self ._http_request (
848+ trace_config = aiohttp_client .create_trace_config (),
849+ url = "/timeout" ,
850+ request_handler = timeout_handler ,
851+ timeout = aiohttp .ClientTimeout (sock_read = 0.01 ),
852+ )
853+
854+ metrics = self ._assert_metrics (1 )
855+ duration_dp_attributes = [
856+ dict (dp .attributes ) for dp in metrics [0 ].data .data_points
857+ ]
858+ self .assertEqual (
859+ [
860+ {
861+ HTTP_METHOD : "GET" ,
862+ HTTP_HOST : success_host ,
863+ HTTP_STATUS_CODE : int (HTTPStatus .OK ),
864+ NET_PEER_NAME : success_host ,
865+ NET_PEER_PORT : success_port ,
866+ },
867+ {
868+ HTTP_METHOD : "GET" ,
869+ HTTP_HOST : timeout_host ,
870+ NET_PEER_NAME : timeout_host ,
871+ NET_PEER_PORT : timeout_port ,
872+ },
873+ ],
874+ duration_dp_attributes ,
875+ )
876+
831877
832878class TestAioHttpClientInstrumentor (TestBase ):
833879 URL = "/test-path"
0 commit comments