summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-03-04 17:13:09 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-03-12 16:24:50 +0000
commite02cc249da6ff71dcc1e5560232b302246a11c9d (patch)
treec1f5f8fdfc79b57436c91cb205d38e5b92cc26f9
parentAdd a scalar gauge metric on the size of the presence user cachemap (diff)
downloadsynapse-e02cc249da6ff71dcc1e5560232b302246a11c9d.tar.xz
Ensure that exceptions while rendering individual metrics don't stop others from being rendered anyway - especially useful for CallbackMetric
Diffstat (limited to '')
-rw-r--r--synapse/metrics/__init__.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py
index d7584fc0bc..d967b04eee 100644
--- a/synapse/metrics/__init__.py
+++ b/synapse/metrics/__init__.py
@@ -13,9 +13,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import logging
+
 from .metric import CounterMetric, CallbackMetric, CacheCounterMetric
 
 
+logger = logging.getLogger(__name__)
+
+
 # We'll keep all the available metrics in a single toplevel dict, one shared
 # for the entire process. We don't currently support per-HomeServer instances
 # of metrics, because in practice any one python VM will host only one
@@ -82,6 +87,10 @@ def render_all():
     strs = []
 
     for name in sorted(all_metrics.keys()):
-        strs += all_metrics[name].render()
+        try:
+            strs += all_metrics[name].render()
+        except Exception as e:
+            strs += ["# FAILED to render %s" % name]
+            logger.exception("Failed to render %s metric", name)
 
     return "\n".join(strs)