diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-01-18 11:30:49 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-01-18 11:30:49 +0000 |
commit | ce236f8ac890842e105fee0df96c79f3d8ab8783 (patch) | |
tree | f3a493d4d647bab459f66e7c78ab11eeb8405c8a /synapse/metrics | |
parent | Merge pull request #2783 from matrix-org/erikj/media_last_accessed (diff) | |
download | synapse-ce236f8ac890842e105fee0df96c79f3d8ab8783.tar.xz |
better exception logging in callbackmetrics
when we fail to render a metric, give a clue as to which metric it was
Diffstat (limited to 'synapse/metrics')
-rw-r--r-- | synapse/metrics/metric.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/synapse/metrics/metric.py b/synapse/metrics/metric.py index f480aae614..1e783e5ff4 100644 --- a/synapse/metrics/metric.py +++ b/synapse/metrics/metric.py @@ -15,6 +15,9 @@ from itertools import chain +import logging + +logger = logging.getLogger(__name__) def flatten(items): @@ -153,7 +156,11 @@ class CallbackMetric(BaseMetric): self.callback = callback def render(self): - value = self.callback() + try: + value = self.callback() + except Exception: + logger.exception("Failed to render %s", self.name) + return ["# FAILED to render " + self.name] if self.is_scalar(): return list(self._render_for_labels([], value)) |