summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-03-12 16:24:38 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-03-12 16:24:51 +0000
commit128cf2daf76e5b05a4e577b60ea406fdbb6986bf (patch)
tree1eeda21c7b8af0d08a57f46a2ec2c81f4fe3f326 /synapse
parentOption to serve metrics from their own localhost-only TCP port instead of mux... (diff)
downloadsynapse-128cf2daf76e5b05a4e577b60ea406fdbb6986bf.tar.xz
Appease pep8
Diffstat (limited to 'synapse')
-rw-r--r--synapse/federation/transaction_queue.py9
-rw-r--r--synapse/handlers/presence.py5
-rw-r--r--synapse/http/client.py10
-rw-r--r--synapse/http/matrixfederationclient.py10
-rw-r--r--synapse/http/server.py8
-rw-r--r--synapse/metrics/__init__.py3
-rw-r--r--synapse/metrics/metric.py11
-rw-r--r--synapse/metrics/resource.py2
-rw-r--r--synapse/notifier.py15
9 files changed, 46 insertions, 27 deletions
diff --git a/synapse/federation/transaction_queue.py b/synapse/federation/transaction_queue.py
index 99e386fa52..4dccd93d0e 100644
--- a/synapse/federation/transaction_queue.py
+++ b/synapse/federation/transaction_queue.py
@@ -57,7 +57,8 @@ class TransactionQueue(object):
         # done
         self.pending_transactions = {}
 
-        metrics.register_callback("pending_destinations",
+        metrics.register_callback(
+            "pending_destinations",
             lambda: len(self.pending_transactions),
         )
 
@@ -67,10 +68,12 @@ class TransactionQueue(object):
         # destination -> list of tuple(edu, deferred)
         self.pending_edus_by_dest = edus = {}
 
-        metrics.register_callback("pending_pdus",
+        metrics.register_callback(
+            "pending_pdus",
             lambda: sum(map(len, pdus.values())),
         )
-        metrics.register_callback("pending_edus",
+        metrics.register_callback(
+            "pending_edus",
             lambda: sum(map(len, edus.values())),
         )
 
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index c6d6aef53b..731df00648 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -136,8 +136,9 @@ class PresenceHandler(BaseHandler):
         self._user_cachemap = {}
         self._user_cachemap_latest_serial = 0
 
-        metrics.register_callback("userCachemap:size",
-            lambda: len(self._user_cachemap)
+        metrics.register_callback(
+            "userCachemap:size",
+            lambda: len(self._user_cachemap),
         )
 
     def _get_or_make_usercache(self, user):
diff --git a/synapse/http/client.py b/synapse/http/client.py
index 01737a7188..2ae1c4d3a4 100644
--- a/synapse/http/client.py
+++ b/synapse/http/client.py
@@ -34,11 +34,13 @@ logger = logging.getLogger(__name__)
 
 metrics = synapse.metrics.get_metrics_for(__name__)
 
-outgoing_requests_counter = metrics.register_counter("requests",
+outgoing_requests_counter = metrics.register_counter(
+    "requests",
     labels=["method"],
 )
-incoming_responses_counter = metrics.register_counter("responses",
-    labels=["method","code"],
+incoming_responses_counter = metrics.register_counter(
+    "responses",
+    labels=["method", "code"],
 )
 
 
@@ -64,9 +66,11 @@ class SimpleHttpClient(object):
         def _cb(response):
             incoming_responses_counter.inc(method, response.code)
             return response
+
         def _eb(failure):
             incoming_responses_counter.inc(method, "ERR")
             return failure
+
         d.addCallbacks(_cb, _eb)
 
         return d
diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py
index 11883d3852..7fa295cad5 100644
--- a/synapse/http/matrixfederationclient.py
+++ b/synapse/http/matrixfederationclient.py
@@ -43,11 +43,13 @@ logger = logging.getLogger(__name__)
 
 metrics = synapse.metrics.get_metrics_for(__name__)
 
-outgoing_requests_counter = metrics.register_counter("requests",
+outgoing_requests_counter = metrics.register_counter(
+    "requests",
     labels=["method"],
 )
-incoming_responses_counter = metrics.register_counter("responses",
-    labels=["method","code"],
+incoming_responses_counter = metrics.register_counter(
+    "responses",
+    labels=["method", "code"],
 )
 
 
@@ -78,9 +80,11 @@ class MatrixFederationHttpAgent(_AgentBase):
         def _cb(response):
             incoming_responses_counter.inc(method, response.code)
             return response
+
         def _eb(failure):
             incoming_responses_counter.inc(method, "ERR")
             return failure
+
         d.addCallbacks(_cb, _eb)
 
         return d
diff --git a/synapse/http/server.py b/synapse/http/server.py
index a0d190ff78..d77cb77799 100644
--- a/synapse/http/server.py
+++ b/synapse/http/server.py
@@ -37,11 +37,13 @@ logger = logging.getLogger(__name__)
 
 metrics = synapse.metrics.get_metrics_for(__name__)
 
-incoming_requests_counter = metrics.register_counter("requests",
+incoming_requests_counter = metrics.register_counter(
+    "requests",
     labels=["method", "servlet"],
 )
-outgoing_responses_counter = metrics.register_counter("responses",
-    labels=["method","code"],
+outgoing_responses_counter = metrics.register_counter(
+    "responses",
+    labels=["method", "code"],
 )
 
 
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py
index 94164974fc..7b9c9c8bab 100644
--- a/synapse/metrics/__init__.py
+++ b/synapse/metrics/__init__.py
@@ -85,7 +85,7 @@ def render_all():
             strs += ["# FAILED to render %s" % name]
             logger.exception("Failed to render %s metric", name)
 
-    strs.append("") # to generate a final CRLF
+    strs.append("")  # to generate a final CRLF
 
     return "\n".join(strs)
 
@@ -96,6 +96,7 @@ def render_all():
 rusage = None
 PAGE_SIZE = getpagesize()
 
+
 def update_resource_metrics():
     global rusage
     rusage = getrusage(RUSAGE_SELF)
diff --git a/synapse/metrics/metric.py b/synapse/metrics/metric.py
index 12460c99c3..21b37748f6 100644
--- a/synapse/metrics/metric.py
+++ b/synapse/metrics/metric.py
@@ -27,7 +27,7 @@ class BaseMetric(object):
 
     def __init__(self, name, labels=[]):
         self.name = name
-        self.labels = labels # 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.labels)
@@ -66,8 +66,8 @@ class CounterMetric(BaseMetric):
 
     def inc_by(self, incr, *values):
         if len(values) != self.dimension():
-            raise ValueError("Expected as many values to inc() as labels (%d)" %
-                (self.dimension())
+            raise ValueError(
+                "Expected as many values to inc() as labels (%d)" % (self.dimension())
             )
 
         # TODO: should assert that the tag values are all strings
@@ -135,10 +135,11 @@ class CacheMetric(object):
     def __init__(self, name, size_callback, labels=[]):
         self.name = name
 
-        self.hits  = CounterMetric(name + ":hits",  labels=labels)
+        self.hits = CounterMetric(name + ":hits", labels=labels)
         self.total = CounterMetric(name + ":total", labels=labels)
 
-        self.size = CallbackMetric(name + ":size",
+        self.size = CallbackMetric(
+            name + ":size",
             callback=size_callback,
             labels=labels,
         )
diff --git a/synapse/metrics/resource.py b/synapse/metrics/resource.py
index ff7baab018..97ea797bf5 100644
--- a/synapse/metrics/resource.py
+++ b/synapse/metrics/resource.py
@@ -26,7 +26,7 @@ class MetricsResource(Resource):
     isLeaf = True
 
     def __init__(self, hs):
-        Resource.__init__(self) # Resource is old-style, so no super()
+        Resource.__init__(self)  # Resource is old-style, so no super()
 
         self.hs = hs
 
diff --git a/synapse/notifier.py b/synapse/notifier.py
index 88873d4534..7121d659d0 100644
--- a/synapse/notifier.py
+++ b/synapse/notifier.py
@@ -127,14 +127,17 @@ class Notifier(object):
             return len(all_listeners)
         metrics.register_callback("listeners", count_listeners)
 
-        metrics.register_callback("rooms",
-            lambda: count(bool, self.room_to_listeners.values())
+        metrics.register_callback(
+            "rooms",
+            lambda: count(bool, self.room_to_listeners.values()),
         )
-        metrics.register_callback("users",
-            lambda: count(bool, self.user_to_listeners.values())
+        metrics.register_callback(
+            "users",
+            lambda: count(bool, self.user_to_listeners.values()),
         )
-        metrics.register_callback("appservices",
-            lambda: count(bool, self.appservice_to_listeners.values())
+        metrics.register_callback(
+            "appservices",
+            lambda: count(bool, self.appservice_to_listeners.values()),
         )
 
     @log_function