summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-03-06 15:28:06 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-03-12 16:24:51 +0000
commitf9478e475bf645038b4f1f163240d7fd0ec02af0 (patch)
tree8f3111db53f48e2918b98b372c7436270846931b /synapse
parentProvide some process resource usage metrics (diff)
downloadsynapse-f9478e475bf645038b4f1f163240d7fd0ec02af0.tar.xz
Rename Metrics' "keys" to "labels"
Diffstat (limited to 'synapse')
-rw-r--r--synapse/federation/transaction_queue.py4
-rw-r--r--synapse/http/client.py4
-rw-r--r--synapse/http/matrixfederationclient.py4
-rw-r--r--synapse/http/server.py4
-rw-r--r--synapse/metrics/metric.py24
-rw-r--r--synapse/storage/_base.py6
6 files changed, 23 insertions, 23 deletions
diff --git a/synapse/federation/transaction_queue.py b/synapse/federation/transaction_queue.py
index b9d3f89324..ae62c69fc3 100644
--- a/synapse/federation/transaction_queue.py
+++ b/synapse/federation/transaction_queue.py
@@ -71,11 +71,11 @@ class TransactionQueue(object):
 
         metrics.register_callback("pending_pdus",
             lambda: {(dest,): len(pdus[dest]) for dest in pdus.keys()},
-            keys=["dest"],
+            labels=["dest"],
         )
         metrics.register_callback("pending_edus",
             lambda: {(dest,): len(edus[dest]) for dest in edus.keys()},
-            keys=["dest"],
+            labels=["dest"],
         )
 
     def can_send_to(self, destination):
diff --git a/synapse/http/client.py b/synapse/http/client.py
index e40e82e80b..ad2c9c05ec 100644
--- a/synapse/http/client.py
+++ b/synapse/http/client.py
@@ -35,10 +35,10 @@ logger = logging.getLogger(__name__)
 metrics = synapse.metrics.get_metrics_for(__name__)
 
 outgoing_requests_counter = metrics.register_counter("outgoing_requests",
-    keys=["method"],
+    labels=["method"],
 )
 incoming_responses_counter = metrics.register_counter("incoming_responses",
-    keys=["method","code"],
+    labels=["method","code"],
 )
 
 
diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py
index 0091527693..6b6d79a044 100644
--- a/synapse/http/matrixfederationclient.py
+++ b/synapse/http/matrixfederationclient.py
@@ -44,10 +44,10 @@ logger = logging.getLogger(__name__)
 metrics = synapse.metrics.get_metrics_for(__name__)
 
 outgoing_requests_counter = metrics.register_counter("outgoing_requests",
-    keys=["method"],
+    labels=["method"],
 )
 incoming_responses_counter = metrics.register_counter("incoming_responses",
-    keys=["method","code"],
+    labels=["method","code"],
 )
 
 
diff --git a/synapse/http/server.py b/synapse/http/server.py
index ac893bb40c..35bd3a00ba 100644
--- a/synapse/http/server.py
+++ b/synapse/http/server.py
@@ -38,10 +38,10 @@ logger = logging.getLogger(__name__)
 metrics = synapse.metrics.get_metrics_for(__name__)
 
 incoming_requests_counter = metrics.register_counter("incoming_requests",
-    keys=["method"],
+    labels=["method"],
 )
 outgoing_responses_counter = metrics.register_counter("outgoing_responses",
-    keys=["method","code"],
+    labels=["method","code"],
 )
 
 
diff --git a/synapse/metrics/metric.py b/synapse/metrics/metric.py
index 4a6ab9cd74..8ba13075f7 100644
--- a/synapse/metrics/metric.py
+++ b/synapse/metrics/metric.py
@@ -25,22 +25,22 @@ def map_concat(func, items):
 
 class BaseMetric(object):
 
-    def __init__(self, name, keys=[]):
+    def __init__(self, name, labels=[]):
         self.name = name
-        self.keys = keys # OK not to clone as we never write it
+        self.labels = labels # OK not to clone as we never write it
 
     def dimension(self):
-        return len(self.keys)
+        return len(self.labels)
 
     def is_scalar(self):
-        return not len(self.keys)
+        return not len(self.labels)
 
     def _render_key(self, values):
         if self.is_scalar():
             return ""
         # TODO: some kind of value escape
         return "{%s}" % (
-            ",".join(["%s=%s" % kv for kv in zip(self.keys, values)])
+            ",".join(["%s=%s" % kv for kv in zip(self.labels, values)])
         )
 
     def render(self):
@@ -62,7 +62,7 @@ class CounterMetric(BaseMetric):
 
     def inc(self, *values):
         if len(values) != self.dimension():
-            raise ValueError("Expected as many values to inc() as keys (%d)" %
+            raise ValueError("Expected as many values to inc() as labels (%d)" %
                 (self.dimension())
             )
 
@@ -85,8 +85,8 @@ class CallbackMetric(BaseMetric):
     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)
+    def __init__(self, name, callback, labels=[]):
+        super(CallbackMetric, self).__init__(name, labels=labels)
 
         self.callback = callback
 
@@ -139,15 +139,15 @@ class CacheMetric(object):
     This metric generates standard metric name pairs, so that monitoring rules
     can easily be applied to measure hit ratio."""
 
-    def __init__(self, name, size_callback, keys=[]):
+    def __init__(self, name, size_callback, labels=[]):
         self.name = name
 
-        self.hits   = CounterMetric(name + ":hits",   keys=keys)
-        self.misses = CounterMetric(name + ":misses", keys=keys)
+        self.hits   = CounterMetric(name + ":hits",   labels=labels)
+        self.misses = CounterMetric(name + ":misses", labels=labels)
 
         self.size = CallbackMetric(name + ":size",
             callback=size_callback,
-            keys=keys,
+            labels=labels,
         )
 
     def inc_hits(self, *values):
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index d8c5a60c71..a38b603584 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -38,9 +38,9 @@ transaction_logger = logging.getLogger("synapse.storage.txn")
 
 metrics = synapse.metrics.get_metrics_for("synapse.storage")
 
-sql_query_timer = metrics.register_timer("queries", keys=["verb"])
-sql_txn_timer = metrics.register_timer("transactions", keys=["desc"])
-sql_getevents_timer = metrics.register_timer("get_events", keys=["desc"])
+sql_query_timer = metrics.register_timer("queries", labels=["verb"])
+sql_txn_timer = metrics.register_timer("transactions", labels=["desc"])
+sql_getevents_timer = metrics.register_timer("get_events", labels=["desc"])
 
 
 # TODO(paul):