diff options
author | Erik Johnston <erik@matrix.org> | 2016-08-08 11:12:21 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-08-08 11:12:21 +0100 |
commit | 7c1a92274c720f125e8c5bb96b85f05734a58943 (patch) | |
tree | c3189b92b1e502551a856dbd7631e373fd7f9e33 /synapse/metrics/__init__.py | |
parent | Merge pull request #991 from matrix-org/erikj/retry_make (diff) | |
download | synapse-7c1a92274c720f125e8c5bb96b85f05734a58943.tar.xz |
Make psutil optional
Diffstat (limited to 'synapse/metrics/__init__.py')
-rw-r--r-- | synapse/metrics/__init__.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py index cce3dba47c..76d5998d75 100644 --- a/synapse/metrics/__init__.py +++ b/synapse/metrics/__init__.py @@ -68,9 +68,18 @@ class Metrics(object): def register_memory_metrics(hs): - metric = MemoryUsageMetric(hs) + try: + import psutil + process = psutil.Process() + process.memory_info().rss + except (ImportError, AttributeError): + logger.warn( + "psutil is not installed or incorrect version." + " Disabling memory metrics." + ) + return + metric = MemoryUsageMetric(hs, psutil) all_metrics.append(metric) - return metric def get_metrics_for(pkg_name): |