mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 01:16:36 +00:00
[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.
This commit is contained in:
parent
78de27aac6
commit
3c518940b0
@ -3,6 +3,7 @@ import time
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
import sys
|
||||
import logging
|
||||
|
||||
import github
|
||||
from github import Github
|
||||
@ -220,7 +221,7 @@ def upload_metrics(workflow_metrics, metrics_userid, api_key):
|
||||
"""
|
||||
|
||||
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 @@ def upload_metrics(workflow_metrics, metrics_userid, api_key):
|
||||
)
|
||||
|
||||
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 @@ def main():
|
||||
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 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user