def _publish_stats(self, counter_prefix, stats, instance):
     """Given a stats dictionary from _get_stats_from_socket,
     publish the individual values.
     """
     for stat_name, stat_value in ceph.flatten_dictionary(
         stats,
         prefix=counter_prefix,
     ):
         self.publish_gauge(stat_name, stat_value, instance=instance)
예제 #2
0
파일: testceph.py 프로젝트: HVF/Diamond
 def test_complex(self):
     data = {"val": 0,
             "max": 524288000,
             "get": 60910,
             "wait": {"avgcount": 0,
                      "sum": 0},
             }
     expected = [
         ('get', 60910),
         ('max', 524288000),
         ('val', 0),
         ('wait.avgcount', 0),
         ('wait.sum', 0),
     ]
     actual = list(ceph.flatten_dictionary(data))
     self.assertSequenceEqual(actual, expected)
예제 #3
0
 def test_complex(self):
     data = {"val": 0,
             "max": 524288000,
             "get": 60910,
             "wait": {"avgcount": 0,
                      "sum": 0},
             }
     expected = [
         ('get', 60910),
         ('max', 524288000),
         ('val', 0),
         ('wait.avgcount', 0),
         ('wait.sum', 0),
     ]
     actual = list(ceph.flatten_dictionary(data))
     self.assertSequenceEqual(actual, expected)
예제 #4
0
 def test_doubly_nested(self):
     data = {'a': 1, 'b': 2, 'c': {'d': 3}, 'e': {'f': {'g': 1}}}
     expected = [('a', 1), ('b', 2), ('c.d', 3), ('e.f.g', 1)]
     actual = list(ceph.flatten_dictionary(data))
     self.assertSequenceEqual(actual, expected)
예제 #5
0
 def test_sep(self):
     data = {'a': 1, 'b': 2}
     expected = [('Z:a', 1), ('Z:b', 2)]
     actual = list(ceph.flatten_dictionary(data, prefix='Z', sep=':'))
     self.assertSequenceEqual(actual, expected)
예제 #6
0
 def test_simple(self):
     data = {'a': 1, 'b': 2}
     expected = [('a', 1), ('b', 2)]
     actual = list(ceph.flatten_dictionary(data))
     self.assertSequenceEqual(actual, expected)
예제 #7
0
 def test_empty(self):
     data = {}
     expected = []
     actual = list(ceph.flatten_dictionary(data))
     self.assertSequenceEqual(actual, expected)
예제 #8
0
파일: testceph.py 프로젝트: HVF/Diamond
 def test_doubly_nested(self):
     data = {'a': 1, 'b': 2, 'c': {'d': 3}, 'e': {'f': {'g': 1}}}
     expected = [('a', 1), ('b', 2), ('c.d', 3), ('e.f.g', 1)]
     actual = list(ceph.flatten_dictionary(data))
     self.assertSequenceEqual(actual, expected)
예제 #9
0
파일: testceph.py 프로젝트: HVF/Diamond
 def test_sep(self):
     data = {'a': 1, 'b': 2}
     expected = [('Z:a', 1), ('Z:b', 2)]
     actual = list(ceph.flatten_dictionary(data, prefix='Z', sep=':'))
     self.assertSequenceEqual(actual, expected)
예제 #10
0
파일: testceph.py 프로젝트: HVF/Diamond
 def test_simple(self):
     data = {'a': 1, 'b': 2}
     expected = [('a', 1), ('b', 2)]
     actual = list(ceph.flatten_dictionary(data))
     self.assertSequenceEqual(actual, expected)
예제 #11
0
파일: testceph.py 프로젝트: HVF/Diamond
 def test_empty(self):
     data = {}
     expected = []
     actual = list(ceph.flatten_dictionary(data))
     self.assertSequenceEqual(actual, expected)