@@ -66,6 +66,40 @@ async def test_metrics(aiohttp_client: AiohttpClient) -> None:
6666 )
6767
6868
69+ async def test_not_handled (aiohttp_client : AiohttpClient ) -> None :
70+ # Arrange
71+ expected_content_type = "text/plain; version=0.0.4; charset=utf-8"
72+
73+ app = Application ()
74+
75+ metrics_cfg = MetricsConfig (
76+ app_name = "test" ,
77+ include_metrics_endpoint = True ,
78+ include_trace_exemplar = False ,
79+ openmetrics_format = False ,
80+ )
81+
82+ setup_metrics (app , metrics_cfg )
83+
84+ client : TestClient = await aiohttp_client (app )
85+
86+ # Act
87+ not_found_response = await client .get ("/not_found" )
88+ response = await client .get ("/metrics" )
89+
90+ # Assert
91+ assert response .headers ["content-type" ] == expected_content_type
92+ assert not_found_response .status == 404
93+ assert response .status == 200
94+ assert_that (await response .text ()).does_not_contain ("not_found" )
95+ assert_that (await response .text ()).contains (
96+ 'aiohttp_app_info{app_name="test"} 1.0' ,
97+ 'aiohttp_requests_total{app_name="test",method="GET",path="/metrics"} 1.0' ,
98+ 'aiohttp_requests_created{app_name="test",method="GET",path="/metrics"}' ,
99+ 'aiohttp_requests_in_progress{app_name="test",method="GET",path="/metrics"} 1.0' ,
100+ )
101+
102+
69103async def test_metrics_global_registry (aiohttp_client : AiohttpClient ) -> None :
70104 # Arrange
71105 app = Application ()
0 commit comments