@@ -1514,6 +1514,45 @@ mod tests {
15141514 . await ;
15151515 }
15161516
1517+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
1518+ async fn view_test_change_name_unit ( ) {
1519+ test_view_customization (
1520+ |i| {
1521+ if i. name == "my_counter" {
1522+ Some ( Stream :: new ( ) . name ( "my_counter_renamed" ) . unit ( "my_unit_new" ) )
1523+ } else {
1524+ None
1525+ }
1526+ } ,
1527+ "my_counter_renamed" ,
1528+ "my_unit_new" ,
1529+ "my_description" ,
1530+ )
1531+ . await ;
1532+ }
1533+
1534+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
1535+ async fn view_test_change_name_unit_desc ( ) {
1536+ test_view_customization (
1537+ |i| {
1538+ if i. name == "my_counter" {
1539+ Some (
1540+ Stream :: new ( )
1541+ . name ( "my_counter_renamed" )
1542+ . unit ( "my_unit_new" )
1543+ . description ( "my_description_new" ) ,
1544+ )
1545+ } else {
1546+ None
1547+ }
1548+ } ,
1549+ "my_counter_renamed" ,
1550+ "my_unit_new" ,
1551+ "my_description_new" ,
1552+ )
1553+ . await ;
1554+ }
1555+
15171556 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
15181557 async fn view_test_match_unit ( ) {
15191558 test_view_customization (
@@ -1548,6 +1587,23 @@ mod tests {
15481587 . await ;
15491588 }
15501589
1590+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
1591+ async fn view_test_match_multiple ( ) {
1592+ test_view_customization (
1593+ |i| {
1594+ if i. name == "my_counter" && i. unit == "my_unit" {
1595+ Some ( Stream :: new ( ) . name ( "my_counter_renamed" ) )
1596+ } else {
1597+ None
1598+ }
1599+ } ,
1600+ "my_counter_renamed" ,
1601+ "my_unit" ,
1602+ "my_description" ,
1603+ )
1604+ . await ;
1605+ }
1606+
15511607 /// Helper function to test view customizations
15521608 async fn test_view_customization < F > (
15531609 view_function : F ,
@@ -1582,7 +1638,8 @@ mod tests {
15821638 let resource_metrics = exporter
15831639 . get_finished_metrics ( )
15841640 . expect ( "metrics are expected to be exported." ) ;
1585- assert ! ( !resource_metrics. is_empty( ) ) ;
1641+ assert_eq ! ( resource_metrics. len( ) , 1 ) ;
1642+ assert_eq ! ( resource_metrics[ 0 ] . scope_metrics. len( ) , 1 ) ;
15861643 let metric = & resource_metrics[ 0 ] . scope_metrics [ 0 ] . metrics [ 0 ] ;
15871644 assert_eq ! (
15881645 metric. name, expected_name,
0 commit comments