(self)
| 81 | self.assertTrue(gauge1.get_cell('foo').value()) |
| 82 | |
| 83 | def test_sampler(self): |
| 84 | buckets = monitoring.ExponentialBuckets(1.0, 2.0, 2) |
| 85 | sampler = monitoring.Sampler('test/sampler', buckets, 'test sampler') |
| 86 | sampler.get_cell().add(1.0) |
| 87 | sampler.get_cell().add(5.0) |
| 88 | histogram_proto = sampler.get_cell().value() |
| 89 | self.assertEqual(histogram_proto.min, 1.0) |
| 90 | self.assertEqual(histogram_proto.num, 2.0) |
| 91 | self.assertEqual(histogram_proto.sum, 6.0) |
| 92 | |
| 93 | sampler1 = monitoring.Sampler('test/sampler1', buckets, 'test sampler', |
| 94 | 'label1') |
| 95 | sampler1.get_cell('foo').add(2.0) |
| 96 | sampler1.get_cell('foo').add(4.0) |
| 97 | sampler1.get_cell('bar').add(8.0) |
| 98 | histogram_proto1 = sampler1.get_cell('foo').value() |
| 99 | self.assertEqual(histogram_proto1.max, 4.0) |
| 100 | self.assertEqual(histogram_proto1.num, 2.0) |
| 101 | self.assertEqual(histogram_proto1.sum, 6.0) |
| 102 | |
| 103 | |
| 104 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected