Exemplo n.º 1
0
    def test_metric_to_obs_item(self):
        config = configobj.ConfigObj()
        handler = ObservabilityHandler(config)

        item = handler._get_queue_item(self.METRICS[0])

        self.assertEqual(item, {
            'service': 'cpu',
            'source': 'com.example.www',
            'name': 'total.idle',
            'value': 1.4,
            'measure_time': 1234567,
        })
Exemplo n.º 2
0
    def test_metric_grouping(self):
        config = configobj.ConfigObj()
        handler = ObservabilityHandler(config)

        items = [handler._get_queue_item(m) for m in self.METRICS]
        groups = handler._create_request_groups(items)

        self.assertEqual(
            set(groups.keys()),
            {('cpu', 'com.example.www2', 1234540),
             ('cpu', 'com.example.www', 1234560),
             ('cpu', 'com.example.www', 1234540)}
        )

        self.assertEqual(len(groups[('cpu', 'com.example.www2', 1234540)]), 1)
        self.assertEqual(len(groups[('cpu', 'com.example.www', 1234560)]), 2)
        self.assertEqual(len(groups[('cpu', 'com.example.www', 1234540)]), 2)