diff options
author | Erik Johnston <erik@matrix.org> | 2016-06-03 11:57:29 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-06-03 11:57:29 +0100 |
commit | 43b7f371f5f1e696a8d4b3ccce1861b6c5473bcb (patch) | |
tree | 0903f9e9e9a2c7464bba93ba862b3ca1bf13a13f /synapse/metrics/__init__.py | |
parent | Merge pull request #829 from matrix-org/erikj/poke_notifier (diff) | |
parent | Change CacheMetrics to be quicker (diff) | |
download | synapse-43b7f371f5f1e696a8d4b3ccce1861b6c5473bcb.tar.xz |
Merge pull request #830 from matrix-org/erikj/metrics_perf
Change CacheMetrics to be quicker
Diffstat (limited to 'synapse/metrics/__init__.py')
-rw-r--r-- | synapse/metrics/__init__.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py index 5664d5a381..c38f24485a 100644 --- a/synapse/metrics/__init__.py +++ b/synapse/metrics/__init__.py @@ -33,11 +33,7 @@ from .metric import ( 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 -# HomeServer anyway. This makes a lot of implementation neater -all_metrics = {} +all_metrics = [] class Metrics(object): @@ -53,7 +49,7 @@ class Metrics(object): metric = metric_class(full_name, *args, **kwargs) - all_metrics[full_name] = metric + all_metrics.append(metric) return metric def register_counter(self, *args, **kwargs): @@ -84,12 +80,12 @@ def render_all(): # TODO(paul): Internal hack update_resource_metrics() - for name in sorted(all_metrics.keys()): + for metric in all_metrics: try: - strs += all_metrics[name].render() + strs += metric.render() except Exception: - strs += ["# FAILED to render %s" % name] - logger.exception("Failed to render %s metric", name) + strs += ["# FAILED to render"] + logger.exception("Failed to render metric") strs.append("") # to generate a final CRLF |