def _call_all_db_functions()

in postgresql_metrics/metrics_logic.py [0:0]


def _call_all_db_functions(db_stats_functions, db_parameters, schedule=False, db_name=None):
    """Iterates through all given statistics functions, calling them with the given parameter.
    The db_parameter can be a database connection or a file path to Postgres data directory,
    depending on the statistics function to call.
    """
    metrics = []
    for (db_metrics_func, interval_s) in db_stats_functions:
        if schedule:
            if not db_name:
                # DB name is given only if we want to make database specific scheduling.
                db_name = "__cluster_global__"
            is_call_required = \
                _is_time_to_call_stats_func_and_update_ts(db_name, db_metrics_func, interval_s)
        else:
            is_call_required = True
        if is_call_required:
            try:
                LOG.debug('calling stats function {}', db_metrics_func.__name__)
                metrics.extend(db_metrics_func(*db_parameters))
            except Exception:
                LOG.exception('failed calling stats function: ' + db_metrics_func.__name__)
    return metrics