def _getSampleRateData(self): test_varz = { 'metric1': { Source(None, 'service1', 'enpoint1', None): _SampleSet(2, [1, 2]), Source(None, 'service1', 'enpoint2', None): _SampleSet(2, [2, 3]) }, 'metric2': { Source(None, 'service1', 'endpoint1', None): _SampleSet(2, [1, 2]), Source(None, 'service2', 'endpoint1', None): _SampleSet(2, [2, 3]) }, 'metric3': { Source('method1', 'service1', None, None): _SampleSet(2, [1, 2]), Source('method2', 'service1', None, None): _SampleSet(2, [2, 3]), }, 'metric4': { Source(None, 'service1', None, 'client1'): _SampleSet(2, [1, 2]), Source(None, 'service1', None, 'client2'): _SampleSet(2, [2, 3]), Source(None, 'service2', None, 'client1'): _SampleSet(2, [4, 5]) }, } return test_varz
def testShortStreamingPercentile(self): source = Source(None, 'test', None, None) metric = 'test' VarzReceiver.VARZ_METRICS.clear() VarzReceiver.VARZ_DATA.clear() VarzReceiver.RegisterMetric(metric, VarzType.AverageTimer) VarzReceiver.RecordPercentileSample(source, metric, 1) VarzReceiver.RecordPercentileSample(source, metric, 2) VarzReceiver.RecordPercentileSample(source, metric, 3) VarzReceiver.RecordPercentileSample(source, metric, 2) aggs = VarzAggregator.Aggregate(VarzReceiver.VARZ_DATA, VarzReceiver.VARZ_METRICS) self.assertEqual(_round(aggs[metric][('test', None)].total, 2), [2.0, 2.0, 2.70, 2.97, 3.0, 3.0])
def testLongStreamingPercentile(self): source = Source(None, 'test', None, None) metric = 'test' VarzReceiver.VARZ_METRICS.clear() VarzReceiver.VARZ_DATA.clear() VarzReceiver.RegisterMetric(metric, VarzType.AverageTimer) random.seed(1) for n in range(10000): VarzReceiver.RecordPercentileSample(source, metric, float(random.randint(0, 100))) aggs = VarzAggregator.Aggregate(VarzReceiver.VARZ_DATA, VarzReceiver.VARZ_METRICS)
def _getSampleData(self): test_varz = { 'metric1': { Source(None, 'service1', 'enpoint1', None): 1, Source(None, 'service1', 'enpoint2', None): 2 }, 'metric2': { Source(None, 'service1', 'endpoint1', None): 1, Source(None, 'service2', 'endpoint1', None): 2 }, 'metric3': { Source('method1', 'service1', None, None): 1, Source('method2', 'service1', None, None): 2, }, 'metric4': { Source(None, "service1", None, "client1"): 1, Source(None, "service1", None, "client2"): 2, Source(None, "service2", None, "client1"): 3, }, } return test_varz
def testLongStreamingPercentile(self): source = Source(None, 'test', None, None) metric = 'test' VarzReceiver.VARZ_METRICS.clear() VarzReceiver.VARZ_DATA.clear() VarzReceiver.RegisterMetric(metric, VarzType.AverageTimer) random.seed(1) for n in xrange(10000): VarzReceiver.RecordPercentileSample(source, metric, float(random.randint(0, 100))) aggs = VarzAggregator.Aggregate(VarzReceiver.VARZ_DATA, VarzReceiver.VARZ_METRICS) self.assertEqual(_round(aggs[metric][('test', None)].total, 2), [50.25, 50, 92.0, 100.0, 100.0, 100.0])