mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 18:04:49 -04:00
Implement vector CallbackMetrics
This commit is contained in:
parent
849300bc73
commit
23ab0c68c2
2 changed files with 23 additions and 3 deletions
|
@ -65,7 +65,7 @@ class CounterMetricTestCase(unittest.TestCase):
|
|||
|
||||
class CallbackMetricTestCase(unittest.TestCase):
|
||||
|
||||
def test_callback(self):
|
||||
def test_scalar(self):
|
||||
d = dict()
|
||||
|
||||
metric = CallbackMetric("size", lambda: len(d))
|
||||
|
@ -80,6 +80,22 @@ class CallbackMetricTestCase(unittest.TestCase):
|
|||
"size 1",
|
||||
])
|
||||
|
||||
def test_vector(self):
|
||||
vals = dict()
|
||||
|
||||
metric = CallbackMetric("values", lambda: vals, keys=["type"])
|
||||
|
||||
self.assertEquals(metric.render(), [])
|
||||
|
||||
# Keys have to be tuples, even if they're 1-element
|
||||
vals[("foo",)] = 1
|
||||
vals[("bar",)] = 2
|
||||
|
||||
self.assertEquals(metric.render(), [
|
||||
"values{type=bar} 2",
|
||||
"values{type=foo} 1",
|
||||
])
|
||||
|
||||
|
||||
class CacheMetricTestCase(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue