def __init__(self, message, classification, cause=None): super(BuildtoolError, self).__init__(message) labels = { 'cause': cause, 'classification': classification } MetricsManager.singleton().inc_counter('BuildtoolError', labels)
def __init__(self, message, classification, cause=None): super(BuildtoolError, self).__init__(message) labels = { 'cause': cause, 'classification': classification } MetricsManager.singleton().inc_counter('BuildtoolError', labels)
def scan_logs_for_install_errors(path): """Scan logfile at path and count specific errors of interest.""" content = io.open(path, 'r', encoding='utf-8').read() match = re.search( "^E:.* Version '([^']+)' for '([^']+)' was not found", content, re.MULTILINE) component = '' cause = 'Unknown' if match: version = match.group(1) component = match.group(2) cause = 'ComponentNotFound' logging.error('"%s" version "%s" does not exist.', component, version) if not match: match = re.search( '.*: No such file or directory$', content, re.MULTILINE) if match: cause = 'FileNotFound' labels = { 'component': component, 'cause': cause } MetricsManager.singleton().inc_counter('InstallSpinnakerError', labels)
def main(): """The main command dispatcher.""" start_time = time.time() from importlib import import_module command_modules = [ import_module(name + '_commands') for name in [ 'apidocs', 'bom', 'changelog', 'container', 'debian', 'halyard', 'image', 'rpm', 'source', 'spinnaker', 'inspection', 'spin', ]] GitRunner.stash_and_clear_auth_env_vars() options, command_registry = init_options_and_registry( sys.argv[1:], command_modules) logging.basicConfig( format='%(levelname).1s %(asctime)s.%(msecs)03d' ' [%(threadName)s.%(process)d] %(message)s', datefmt='%H:%M:%S', level=STANDARD_LOG_LEVELS[options.log_level]) logging.debug( 'Running with options:\n %s', '\n '.join(yaml.safe_dump(vars(options), default_flow_style=False) .split('\n'))) factory = command_registry.get(options.command) if not factory: logging.error('Unknown command "%s"', options.command) return -1 MetricsManager.startup_metrics(options) labels = {'command': options.command} success = False try: command = factory.make_command(options) command() success = True finally: labels['success'] = success MetricsManager.singleton().observe_timer( 'BuildTool_Outcome', labels, time.time() - start_time) MetricsManager.shutdown_metrics() return 0
def main(): """The main command dispatcher.""" start_time = time.time() from importlib import import_module command_modules = [ import_module(name + "_commands") for name in [ "apidocs", "bom", "changelog", "halyard", "image", "source", "spinnaker", "inspection", ] ] GitRunner.stash_and_clear_auth_env_vars() options, command_registry = init_options_and_registry( sys.argv[1:], command_modules) logging.basicConfig( format="%(levelname).1s %(asctime)s.%(msecs)03d" " [%(threadName)s.%(process)d] %(message)s", datefmt="%H:%M:%S", level=STANDARD_LOG_LEVELS[options.log_level], ) logging.debug( "Running with options:\n %s", "\n ".join( yaml.safe_dump(vars(options), default_flow_style=False).split("\n")), ) factory = command_registry.get(options.command) if not factory: logging.error('Unknown command "%s"', options.command) return -1 MetricsManager.startup_metrics(options) labels = {"command": options.command} success = False try: command = factory.make_command(options) command() success = True finally: labels["success"] = success MetricsManager.singleton().observe_timer("BuildTool_Outcome", labels, time.time() - start_time) MetricsManager.shutdown_metrics() return 0
def main(): """The main command dispatcher.""" start_time = time.time() from importlib import import_module command_modules = [ import_module(name + '_commands') for name in [ 'apidocs', 'bom', 'changelog', 'container', 'debian', 'halyard', 'image', 'rpm', 'source', 'spinnaker', 'inspection', 'spin', ]] GitRunner.stash_and_clear_auth_env_vars() options, command_registry = init_options_and_registry( sys.argv[1:], command_modules) logging.basicConfig( format='%(levelname).1s %(asctime)s.%(msecs)03d' ' [%(threadName)s.%(process)d] %(message)s', datefmt='%H:%M:%S', level=STANDARD_LOG_LEVELS[options.log_level]) logging.debug( 'Running with options:\n %s', '\n '.join(yaml.safe_dump(vars(options), default_flow_style=False) .split('\n'))) factory = command_registry.get(options.command) if not factory: logging.error('Unknown command "%s"', options.command) return -1 MetricsManager.startup_metrics(options) labels = {'command': options.command} success = False try: command = factory.make_command(options) command() success = True finally: labels['success'] = success MetricsManager.singleton().observe_timer( 'BuildTool_Outcome', labels, time.time() - start_time) MetricsManager.shutdown_metrics() return 0
def scan_logs_for_install_errors(path): """Scan logfile at path and count specific errors of interest.""" content = open(path, 'r').read() match = re.search("^E:.* Version '([^']+)' for '([^']+)' was not found", content, re.MULTILINE) component = '' cause = 'Unknown' if match: version = match.group(1) component = match.group(2) cause = 'ComponentNotFound' logging.error('"%s" version "%s" does not exist.', component, version) if not match: match = re.search('.*: No such file or directory$', content, re.MULTILINE) if match: cause = 'FileNotFound' labels = {'component': component, 'cause': cause} MetricsManager.singleton().inc_counter('InstallSpinnakerError', labels)
def scan_logs_for_install_errors(path): """Scan logfile at path and count specific errors of interest.""" content = io.open(path, "r", encoding="utf-8").read() match = re.search("^E:.* Version '([^']+)' for '([^']+)' was not found", content, re.MULTILINE) component = "" cause = "Unknown" if match: version = match.group(1) component = match.group(2) cause = "ComponentNotFound" logging.error('"%s" version "%s" does not exist.', component, version) if not match: match = re.search(".*: No such file or directory$", content, re.MULTILINE) if match: cause = "FileNotFound" labels = {"component": component, "cause": cause} MetricsManager.singleton().inc_counter("InstallSpinnakerError", labels)
def __init__(self, factory, options): self.__factory = factory self.__options = options self.__metrics = MetricsManager.singleton()
def __init__(self, message, classification, cause=None): super(BuildtoolError, self).__init__(message) labels = {"cause": cause, "classification": classification} MetricsManager.singleton().inc_counter("BuildtoolError", labels)