mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 11:16:07 -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
|
@ -62,6 +62,20 @@ class CounterMetric(BaseMetric):
|
|||
for k in sorted(self.counts.keys())]
|
||||
|
||||
|
||||
class CallbackMetric(BaseMetric):
|
||||
"""A metric that returns the numeric value returned by a callback whenever
|
||||
it is rendered. Typically this is used to implement gauges that yield the
|
||||
size or other state of some in-memory object by actively querying it."""
|
||||
|
||||
def __init__(self, name, callback, keys=[]):
|
||||
super(CallbackMetric, self).__init__(name, keys=keys)
|
||||
|
||||
self.callback = callback
|
||||
|
||||
def render(self):
|
||||
# TODO(paul): work out something we can do with keys and vectors
|
||||
return ["%s %d" % (self.name, self.callback())]
|
||||
|
||||
class CacheCounterMetric(object):
|
||||
"""A combination of two CounterMetrics, one to count cache hits and one to
|
||||
count misses.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue