diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-12 15:33:53 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-12 16:24:51 +0000 |
commit | e0214a263b610f21d59d16cf84b5a3eee8485b28 (patch) | |
tree | 466be4f21d296116871443c99ed3031d8dabb10c /synapse/app | |
parent | Bugfix to sql_txn_timer increment - add only the per-TXN duration, not the to... (diff) | |
download | synapse-e0214a263b610f21d59d16cf84b5a3eee8485b28.tar.xz |
Build MetricsResource as a specific HomeServer dependency
Diffstat (limited to 'synapse/app')
-rwxr-xr-x | synapse/app/homeserver.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index 9747f7a015..3801302c60 100755 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -47,6 +47,7 @@ from synapse.crypto import context_factory from synapse.util.logcontext import LoggingContext from synapse.rest.client.v1 import ClientV1RestResource from synapse.rest.client.v2_alpha import ClientV2AlphaRestResource +from synapse.metrics.resource import MetricsResource, METRICS_PREFIX from daemonize import Daemonize import twisted.manhole.telnet @@ -100,6 +101,12 @@ class SynapseHomeServer(HomeServer): def build_resource_for_server_key(self): return LocalKey(self) + def build_resource_for_metrics(self): + if self.get_config().enable_metrics: + return MetricsResource(self) + else: + return None + def build_db_pool(self): return adbapi.ConnectionPool( "sqlite3", self.get_db_name(), @@ -147,12 +154,9 @@ class SynapseHomeServer(HomeServer): else: self.root_resource = Resource() - if self.get_config().enable_metrics: - from synapse.metrics.resource import ( - MetricsResource, METRICS_PREFIX - ) - - desired_tree.append((METRICS_PREFIX, MetricsResource(self))) + metrics_resource = self.get_resource_for_metrics() + if metrics_resource is not None: + desired_tree.append((METRICS_PREFIX, metrics_resource)) # ideally we'd just use getChild and putChild but getChild doesn't work # unless you give it a Request object IN ADDITION to the name :/ So |