[CI] Make Metrics Container Use Python Logging This patch makes the metrics container use the python logging library. This is more of what we want given we're essentially just logging the status of things. It also means we do not have to explicitly specify an output file and lets us control verbosity a bit more cleanly.
diff --git a/.ci/metrics/metrics.py b/.ci/metrics/metrics.py index 354b505..0dc61db 100644 --- a/.ci/metrics/metrics.py +++ b/.ci/metrics/metrics.py
@@ -3,6 +3,7 @@ import os from dataclasses import dataclass import sys +import logging import github from github import Github @@ -220,7 +221,7 @@ """ if len(workflow_metrics) == 0: - print("No metrics found to upload.", file=sys.stderr) + logging.info("No metrics found to upload.") return metrics_batch = [] @@ -249,9 +250,7 @@ ) if response.status_code < 200 or response.status_code >= 300: - print( - f"Failed to submit data to Grafana: {response.status_code}", file=sys.stderr - ) + logging.info(f"Failed to submit data to Grafana: {response.status_code}") def main(): @@ -275,7 +274,7 @@ current_metrics += get_sampled_workflow_metrics(github_repo) upload_metrics(current_metrics, grafana_metrics_userid, grafana_api_key) - print(f"Uploaded {len(current_metrics)} metrics", file=sys.stderr) + logging.info(f"Uploaded {len(current_metrics)} metrics") for workflow_metric in reversed(current_metrics): if isinstance(workflow_metric, JobMetrics): @@ -287,4 +286,5 @@ if __name__ == "__main__": + logging.basicConfig(level=logging.INFO) main()