@@ -94,7 +94,7 @@ impl Fixture {
9494 let metrics = client:: http1 ( proxy. admin , "localhost" ) ;
9595
9696 let client = client:: new ( proxy. outbound , "tele.test.svc.cluster.local" ) ;
97- let tcp_labels = metrics:: labels ( ) . label ( "direction" , "outbound" )
97+ let tcp_labels = metrics:: labels ( ) . label ( "direction" , "outbound" ) ;
9898 let labels = tcp_labels. clone ( ) ;
9999 let tcp_src_labels = tcp_labels. clone ( ) . label ( "peer" , "src" ) ;
100100 let tcp_dst_labels = tcp_labels. label ( "peer" , "dst" ) ;
@@ -299,14 +299,24 @@ async fn test_http_count(metric_name: &str, fixture: impl Future<Output = Fixtur
299299 ..
300300 } = fixture. await ;
301301
302- let metric = labels. metric ( metric_name) ;
302+ // Instead of checking that the metric doesn't exist at all, check that the
303+ // specific metric with service name matching the test doesn't exist.
304+ // This avoids the issue with the admin metrics endpoint counting its own calls.
305+ let test_specific_metric = labels
306+ . metric ( metric_name)
307+ . label ( "srv_name" , "tele.test.svc.cluster.local" ) ;
308+
303309 let scrape = metrics. get ( "/metrics" ) . await ;
310+ assert ! (
311+ test_specific_metric. is_not_in( scrape) ,
312+ "{test_specific_metric:?} should not be in /metrics"
313+ ) ;
304314
305315 info ! ( "client.get(/)" ) ;
306316 assert_eq ! ( client. get( "/" ) . await , "hello" ) ;
307317
308318 // after seeing a request, the request carry the correct labels
309- metric . assert_in ( & metrics) . await ;
319+ test_specific_metric . assert_in ( & metrics) . await ;
310320}
311321
312322mod response_classification {
@@ -1187,7 +1197,7 @@ async fn metrics_compression() {
11871197 info ! ( "client.get(/)" ) ;
11881198 assert_eq ! ( client. get( "/" ) . await , "hello" ) ;
11891199
1190- let mut metric = labels
1200+ let metric = labels
11911201 . metric ( "response_latency_ms_count" )
11921202 . label ( "status_code" , 200 ) ;
11931203
0 commit comments