Make psutil optional

This commit is contained in:
Erik Johnston 2016-08-08 11:12:21 +01:00
parent f5deaff424
commit 7c1a92274c
3 changed files with 16 additions and 6 deletions

View file

@ -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):