def test_start_time_set(self): g1 = GaugeCell() g1.set(3) name = MetricName('namespace', 'name1') mi = g1.to_runner_api_monitoring_info(name, 'transform_id') self.assertGreater(mi.start_time.seconds, 0)
def test_basic_operations(self): g = GaugeCell() g.set(10) self.assertEqual(g.get_cumulative().value, GaugeData(10).value) g.set(2) self.assertEqual(g.get_cumulative().value, 2)
def test_combine_appropriately(self): g1 = GaugeCell() g1.set(3) g2 = GaugeCell() g2.set(1) # THe second Gauge, with value 1 was the most recent, so it should be # the final result. result = g2.combine(g1) self.assertEqual(result.data.value, 1)
def __init__(self, step_name): self.step_name = step_name self.counters = defaultdict(lambda: CounterCell()) self.distributions = defaultdict(lambda: DistributionCell()) self.gauges = defaultdict(lambda: GaugeCell())
def test_integer_only(self): g = GaugeCell() g.set(3.3) self.assertEqual(g.get_cumulative().value, 3)
def test_int64_user_gauge(self): metric = GaugeCell().get_cumulative() result = monitoring_infos.int64_user_gauge('gaugenamespace', 'gaugename', metric) _, gauge_value = monitoring_infos.extract_gauge_value(result) self.assertEqual(0, gauge_value)