diff --git a/rhodecode/apps/ssh_support/lib/ssh_wrapper.py b/rhodecode/apps/ssh_support/lib/ssh_wrapper.py --- a/rhodecode/apps/ssh_support/lib/ssh_wrapper.py +++ b/rhodecode/apps/ssh_support/lib/ssh_wrapper.py @@ -18,6 +18,7 @@ import os import sys +import time import logging import click @@ -25,6 +26,7 @@ import click from pyramid.paster import setup_logging from rhodecode.lib.pyramid_utils import bootstrap +from rhodecode.lib.statsd_client import StatsdClient from .backends import SshWrapper log = logging.getLogger(__name__) @@ -65,8 +67,9 @@ def main(ini_path, mode, user, user_id, 'Please make sure this is set and available during execution ' 'of this script.') connection_info = os.environ.get('SSH_CONNECTION', '') - + time_start = time.time() with bootstrap(ini_path, env={'RC_CMD_SSH_WRAPPER': '1'}) as env: + statsd = StatsdClient.statsd try: ssh_wrapper = SshWrapper( command, connection_info, mode, @@ -74,6 +77,10 @@ def main(ini_path, mode, user, user_id, except Exception: log.exception('Failed to execute SshWrapper') sys.exit(-5) - return_code = ssh_wrapper.wrap() + operation_took = time.time() - time_start + if statsd: + operation_took_ms = round(1000.0 * operation_took) + statsd.timing("rhodecode_ssh_wrapper_timing.histogram", operation_took_ms, + use_decimals=False) sys.exit(return_code)