def render_logs_progress():
    valid_checks = sorted(get_valid_checks())
    total_checks = len(valid_checks)
    checks_with_logs = 0

    lines = ['## Logs support', '', None, '', '??? check "Completed"']

    for check in valid_checks:
        status = None

        if not is_tile_only(check):
            status = ' '
            config_file = get_config_file(check)

            with open(config_file, 'r', encoding='utf-8') as f:
                if '# logs:' in f.read():
                    status = 'X'
                    checks_with_logs += 1
        else:
            readme_file = get_readme_file(check)
            if os.path.exists(readme_file):
                with open(readme_file, 'r', encoding='utf-8') as f:
                    if '# Log collection' in f.read():
                        status = 'X'
                        checks_with_logs += 1
            if status != 'X':
                total_checks -= 1  # we cannot really add log collection to tile only integrations

        if status is not None:
            lines.append(f'    - [{status}] {check}')

    percent = checks_with_logs / total_checks * 100
    formatted_percent = f'{percent:.2f}'
    lines[2] = f'[={formatted_percent}% "{formatted_percent}%"]'
    return lines
Beispiel #2
0
def render_logs_progress():
    not_possible = {
        'sap_hana'  # https://github.com/DataDog/architecture/blob/master/rfcs/agent-integrations/sap_hana.md#open-questions
    }
    valid_checks = sorted(set(get_valid_checks()).difference(not_possible))
    total_checks = len(valid_checks)
    checks_with_logs = 0

    lines = ['## Logs support', '', None, '', '??? check "Completed"']

    for check in valid_checks:
        status = None
        has_logs = False
        tile_only = is_tile_only(check)

        if not tile_only:
            status = ' '
            config_file = get_config_file(check)

            with open(config_file, 'r', encoding='utf-8') as f:
                if '# logs:' in f.read():
                    status = 'X'
                    checks_with_logs += 1
                    has_logs = True

        if not has_logs:
            readme_file = get_readme_file(check)
            if os.path.exists(readme_file):
                with open(readme_file, 'r', encoding='utf-8') as f:
                    if '# Log collection' in f.read():
                        status = 'X'
                        checks_with_logs += 1
            if status != 'X' and tile_only:
                total_checks -= 1  # we cannot really add log collection to tile only integrations

        if status is not None:
            lines.append(f'    - [{status}] {check}')

    percent = checks_with_logs / total_checks * 100
    formatted_percent = f'{percent:.2f}'
    lines[2] = f'[={formatted_percent}% "{formatted_percent}%"]'
    return lines