@@ -266,30 +266,20 @@ async fn admin_transport_metrics() {
266266 ) ;
267267}
268268
269- #[ tokio:: test]
270- async fn metrics_endpoint_inbound_request_count ( ) {
271- test_http_count ( "request_total" , "inbound" , Fixture :: inbound ( ) ) . await ;
272- }
273-
274269#[ tokio:: test]
275270async fn metrics_endpoint_outbound_request_count ( ) {
276- test_http_count ( "request_total" , "outbound" , Fixture :: outbound ( ) ) . await
277- }
278-
279- #[ tokio:: test]
280- async fn metrics_endpoint_inbound_response_count ( ) {
281- test_http_count ( "response_total" , "inbound" , Fixture :: inbound ( ) ) . await ;
271+ test_http_count ( "request_total" , Fixture :: outbound ( ) , 1u64 ) . await
282272}
283273
284274#[ tokio:: test]
285275async fn metrics_endpoint_outbound_response_count ( ) {
286- test_http_count ( "response_total" , "outbound" , Fixture :: outbound ( ) ) . await
276+ test_http_count ( "response_total" , Fixture :: outbound ( ) , 1u64 ) . await
287277}
288278
289279async fn test_http_count (
290280 metric : & str ,
291- traffic_direction : & str ,
292281 fixture : impl Future < Output = Fixture > ,
282+ expected_count : u64 ,
293283) {
294284 let _trace = trace_init ( ) ;
295285 let Fixture {
@@ -303,23 +293,12 @@ async fn test_http_count(
303293 ..
304294 } = fixture. await ;
305295
306- // Add extra cardinality for http counts test only to make sure the test server doesn't to +=1
307- // to existing metrics after the target_addr label is removed.
308- // The combinations are inbound_request, inbound_response, outbound_request, outbound_response
309- let expected_labels = labels. clone ( ) . label (
310- "test_case" ,
311- format ! ( "{}_{}" , "dst_deployment" , traffic_direction) ,
312- ) ;
313-
314- let metric = expected_labels. metric ( metric) ;
315-
316- assert ! ( metric. is_not_in( metrics. get( "/metrics" ) . await ) ) ;
296+ let metric = labels. metric ( metric) ;
317297
318298 info ! ( "client.get(/)" ) ;
319299 assert_eq ! ( client. get( "/" ) . await , "hello" ) ;
320300
321- // after seeing a request, the request count should be 1.
322- metric. value ( 1u64 ) . assert_in ( & metrics) . await ;
301+ metric. value ( expected_count) . assert_in ( & metrics) . await ;
323302}
324303
325304mod response_classification {
@@ -407,7 +386,6 @@ mod response_classification {
407386 "success"
408387 } ,
409388 )
410- . value ( 1u64 )
411389 . assert_in ( & metrics)
412390 . await ;
413391 }
@@ -1196,10 +1174,9 @@ async fn metrics_compression() {
11961174 info ! ( "client.get(/)" ) ;
11971175 assert_eq ! ( client. get( "/" ) . await , "hello" ) ;
11981176
1199- let mut metric = labels
1177+ let metric = labels
12001178 . metric ( "response_latency_ms_count" )
1201- . label ( "status_code" , 200 )
1202- . value ( 1u64 ) ;
1179+ . label ( "status_code" , 200 ) ;
12031180
12041181 for & encoding in encodings {
12051182 assert_eventually_contains ! ( do_scrape( encoding) . await , & metric) ;
@@ -1209,6 +1186,6 @@ async fn metrics_compression() {
12091186 assert_eq ! ( client. get( "/" ) . await , "hello" ) ;
12101187
12111188 for & encoding in encodings {
1212- assert_eventually_contains ! ( do_scrape( encoding) . await , metric. set_value ( 2u64 ) ) ;
1189+ assert_eventually_contains ! ( do_scrape( encoding) . await , metric) ;
12131190 }
12141191}
0 commit comments