mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 21:34:51 -04:00
Initial attempt at a scalar callback-based metric to give instantaneous snapshot gauges
This commit is contained in:
parent
b0cdf097f4
commit
d8caa5454d
3 changed files with 45 additions and 2 deletions
|
@ -15,7 +15,9 @@
|
|||
|
||||
from tests import unittest
|
||||
|
||||
from synapse.metrics.metric import CounterMetric, CacheCounterMetric
|
||||
from synapse.metrics.metric import (
|
||||
CounterMetric, CallbackMetric, CacheCounterMetric
|
||||
)
|
||||
|
||||
|
||||
class CounterMetricTestCase(unittest.TestCase):
|
||||
|
@ -61,6 +63,24 @@ class CounterMetricTestCase(unittest.TestCase):
|
|||
])
|
||||
|
||||
|
||||
class CallbackMetricTestCase(unittest.TestCase):
|
||||
|
||||
def test_callback(self):
|
||||
d = dict()
|
||||
|
||||
metric = CallbackMetric("size", lambda: len(d))
|
||||
|
||||
self.assertEquals(metric.render(), [
|
||||
"size 0",
|
||||
])
|
||||
|
||||
d["key"] = "value"
|
||||
|
||||
self.assertEquals(metric.render(), [
|
||||
"size 1",
|
||||
])
|
||||
|
||||
|
||||
class CacheCounterMetricTestCase(unittest.TestCase):
|
||||
|
||||
def test_cachecounter(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue