# HG changeset patch # User Serhii Ilin # Date 2024-01-17 15:19:42 # Node ID 39887b2aec8281a0ada6e55a1a80c39292f3787d # Parent 9a7f2cde5af4cb0422be6d5d0c7c9e31c53b3fa9 feat(metric): added new metric calculation. Fixes: RCCE-5 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)