@@ -268,28 +268,32 @@ async fn admin_transport_metrics() {
268268
269269#[ tokio:: test]
270270async fn metrics_endpoint_inbound_request_count ( ) {
271- test_http_count ( "request_total" , "inbound" , Fixture :: inbound ( ) ) . await ;
271+ // For inbound traffic, as all traffic goes to the same server and we reduced cardinality,
272+ // the expected request count is 6
273+ test_http_count ( "request_total" , Fixture :: inbound ( ) , 6u64 ) . await ;
272274}
273275
274276#[ tokio:: test]
275277async fn metrics_endpoint_outbound_request_count ( ) {
276- test_http_count ( "request_total" , "outbound" , Fixture :: outbound ( ) ) . await
278+ test_http_count ( "request_total" , Fixture :: outbound ( ) , 1u64 ) . await
277279}
278280
279281#[ tokio:: test]
280282async fn metrics_endpoint_inbound_response_count ( ) {
281- test_http_count ( "response_total" , "inbound" , Fixture :: inbound ( ) ) . await ;
283+ // For inbound traffic, as all traffic goes to the same server and we reduced cardinality,
284+ // the expected request count is 6
285+ test_http_count ( "response_total" , Fixture :: inbound ( ) , 6u64 ) . await ;
282286}
283287
284288#[ tokio:: test]
285289async fn metrics_endpoint_outbound_response_count ( ) {
286- test_http_count ( "response_total" , "outbound" , Fixture :: outbound ( ) ) . await
290+ test_http_count ( "response_total" , Fixture :: outbound ( ) , 1u64 ) . await
287291}
288292
289293async fn test_http_count (
290294 metric : & str ,
291- traffic_direction : & str ,
292295 fixture : impl Future < Output = Fixture > ,
296+ expected_count : u64 ,
293297) {
294298 let _trace = trace_init ( ) ;
295299 let Fixture {
@@ -303,23 +307,12 @@ async fn test_http_count(
303307 ..
304308 } = fixture. await ;
305309
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 ) ) ;
310+ let metric = labels. metric ( metric) ;
317311
318312 info ! ( "client.get(/)" ) ;
319313 assert_eq ! ( client. get( "/" ) . await , "hello" ) ;
320314
321- // after seeing a request, the request count should be 1.
322- metric. value ( 1u64 ) . assert_in ( & metrics) . await ;
315+ metric. value ( expected_count) . assert_in ( & metrics) . await ;
323316}
324317
325318mod response_classification {
@@ -1198,8 +1191,7 @@ async fn metrics_compression() {
11981191
11991192 let mut metric = labels
12001193 . metric ( "response_latency_ms_count" )
1201- . label ( "status_code" , 200 )
1202- . value ( 1u64 ) ;
1194+ . label ( "status_code" , 200 ) ;
12031195
12041196 for & encoding in encodings {
12051197 assert_eventually_contains ! ( do_scrape( encoding) . await , & metric) ;
0 commit comments