summary refs log tree commit diff
path: root/synapse/metrics
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-03-09 20:35:33 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-03-12 16:24:51 +0000
commitcbc0406be844894cac08c457544f1eb0c28435bb (patch)
tree1bb063df91f3d49ba6824aadc502045ac3819b97 /synapse/metrics
parentCount incoming HTTP requests per servlet that responds (diff)
downloadsynapse-cbc0406be844894cac08c457544f1eb0c28435bb.tar.xz
Export CacheMetric as hits+total, rather than hits+misses, as it's easier to derive hit ratio from that
Diffstat (limited to 'synapse/metrics')
-rw-r--r--synapse/metrics/metric.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/synapse/metrics/metric.py b/synapse/metrics/metric.py
index 922cb5a6f1..6b7d3358bc 100644
--- a/synapse/metrics/metric.py
+++ b/synapse/metrics/metric.py
@@ -134,7 +134,7 @@ class TimerMetric(CounterMetric):
 
 class CacheMetric(object):
     """A combination of two CounterMetrics, one to count cache hits and one to
-    count misses, and a callback metric to yield the current size.
+    count a total, and a callback metric to yield the current size.
 
     This metric generates standard metric name pairs, so that monitoring rules
     can easily be applied to measure hit ratio."""
@@ -142,8 +142,8 @@ class CacheMetric(object):
     def __init__(self, name, size_callback, labels=[]):
         self.name = name
 
-        self.hits   = CounterMetric(name + ":hits",   labels=labels)
-        self.misses = CounterMetric(name + ":misses", labels=labels)
+        self.hits  = CounterMetric(name + ":hits",  labels=labels)
+        self.total = CounterMetric(name + ":total", labels=labels)
 
         self.size = CallbackMetric(name + ":size",
             callback=size_callback,
@@ -152,9 +152,10 @@ class CacheMetric(object):
 
     def inc_hits(self, *values):
         self.hits.inc(*values)
+        self.total.inc(*values)
 
     def inc_misses(self, *values):
-        self.misses.inc(*values)
+        self.total.inc(*values)
 
     def render(self):
-        return self.hits.render() + self.misses.render() + self.size.render()
+        return self.hits.render() + self.total.render() + self.size.render()