@@ -1446,7 +1446,7 @@ def test_group_by_key_with_empty_pcoll_elements(self):
1446
1446
# the sampling counter.
1447
1447
class FnApiRunnerMetricsTest (unittest .TestCase ):
1448
1448
def assert_has_counter (
1449
- self , mon_infos , urn , labels , value = None , ge_value = None ):
1449
+ self , mon_infos , urn , labels , value = None , ge_value = None , total_stages = 1 ):
1450
1450
# TODO(ajamato): Consider adding a matcher framework
1451
1451
found = 0
1452
1452
matches = []
@@ -1464,7 +1464,7 @@ def assert_has_counter(
1464
1464
ge_value_str = {'ge_value' : ge_value } if ge_value else ''
1465
1465
value_str = {'value' : value } if value else ''
1466
1466
self .assertEqual (
1467
- 1 ,
1467
+ total_stages ,
1468
1468
found ,
1469
1469
"Found (%s, %s) Expected only 1 monitoring_info for %s." % (
1470
1470
found ,
@@ -1473,7 +1473,15 @@ def assert_has_counter(
1473
1473
))
1474
1474
1475
1475
def assert_has_distribution (
1476
- self , mon_infos , urn , labels , sum = None , count = None , min = None , max = None ):
1476
+ self ,
1477
+ mon_infos ,
1478
+ urn ,
1479
+ labels ,
1480
+ sum = None ,
1481
+ count = None ,
1482
+ min = None ,
1483
+ max = None ,
1484
+ total_stages = 1 ):
1477
1485
# TODO(ajamato): Consider adding a matcher framework
1478
1486
sum = _matcher_or_equal_to (sum )
1479
1487
count = _matcher_or_equal_to (count )
@@ -1508,7 +1516,7 @@ def assert_has_distribution(
1508
1516
increment = 0
1509
1517
found += increment
1510
1518
self .assertEqual (
1511
- 1 ,
1519
+ total_stages ,
1512
1520
found ,
1513
1521
"Found (%s) Expected only 1 monitoring_info for %s." % (
1514
1522
found ,
@@ -1597,15 +1605,17 @@ def process(self, element):
1597
1605
counters ,
1598
1606
monitoring_infos .ELEMENT_COUNT_URN ,
1599
1607
labels ,
1600
- num_source_elems )
1608
+ num_source_elems ,
1609
+ total_stages = 2 )
1601
1610
self .assert_has_distribution (
1602
1611
counters ,
1603
1612
monitoring_infos .SAMPLED_BYTE_SIZE_URN ,
1604
1613
labels ,
1605
1614
min = hamcrest .greater_than (0 ),
1606
1615
max = hamcrest .greater_than (0 ),
1607
1616
sum = hamcrest .greater_than (0 ),
1608
- count = hamcrest .greater_than (0 ))
1617
+ count = hamcrest .greater_than (0 ),
1618
+ total_stages = 2 )
1609
1619
1610
1620
# GenerateTwoOutputs, "SecondOutput" output.
1611
1621
labels = {
@@ -1615,15 +1625,17 @@ def process(self, element):
1615
1625
counters ,
1616
1626
monitoring_infos .ELEMENT_COUNT_URN ,
1617
1627
labels ,
1618
- 2 * num_source_elems )
1628
+ 2 * num_source_elems ,
1629
+ total_stages = 2 )
1619
1630
self .assert_has_distribution (
1620
1631
counters ,
1621
1632
monitoring_infos .SAMPLED_BYTE_SIZE_URN ,
1622
1633
labels ,
1623
1634
min = hamcrest .greater_than (0 ),
1624
1635
max = hamcrest .greater_than (0 ),
1625
1636
sum = hamcrest .greater_than (0 ),
1626
- count = hamcrest .greater_than (0 ))
1637
+ count = hamcrest .greater_than (0 ),
1638
+ total_stages = 2 )
1627
1639
1628
1640
# GenerateTwoOutputs, "ThirdOutput" output.
1629
1641
labels = {
@@ -1633,15 +1645,17 @@ def process(self, element):
1633
1645
counters ,
1634
1646
monitoring_infos .ELEMENT_COUNT_URN ,
1635
1647
labels ,
1636
- num_source_elems )
1648
+ num_source_elems ,
1649
+ total_stages = 2 )
1637
1650
self .assert_has_distribution (
1638
1651
counters ,
1639
1652
monitoring_infos .SAMPLED_BYTE_SIZE_URN ,
1640
1653
labels ,
1641
1654
min = hamcrest .greater_than (0 ),
1642
1655
max = hamcrest .greater_than (0 ),
1643
1656
sum = hamcrest .greater_than (0 ),
1644
- count = hamcrest .greater_than (0 ))
1657
+ count = hamcrest .greater_than (0 ),
1658
+ total_stages = 2 )
1645
1659
1646
1660
# Skipping other pcollections due to non-deterministic naming for multiple
1647
1661
# outputs.
@@ -1653,15 +1667,17 @@ def process(self, element):
1653
1667
counters ,
1654
1668
monitoring_infos .ELEMENT_COUNT_URN ,
1655
1669
labels ,
1656
- 4 * num_source_elems )
1670
+ 4 * num_source_elems ,
1671
+ total_stages = 2 )
1657
1672
self .assert_has_distribution (
1658
1673
counters ,
1659
1674
monitoring_infos .SAMPLED_BYTE_SIZE_URN ,
1660
1675
labels ,
1661
1676
min = hamcrest .greater_than (0 ),
1662
1677
max = hamcrest .greater_than (0 ),
1663
1678
sum = hamcrest .greater_than (0 ),
1664
- count = hamcrest .greater_than (0 ))
1679
+ count = hamcrest .greater_than (0 ),
1680
+ total_stages = 2 )
1665
1681
1666
1682
# PassThrough, main output
1667
1683
labels = {
0 commit comments