Skip to content

Commit 3c51894

Browse files
[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.
1 parent 78de27a commit 3c51894

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

.ci/metrics/metrics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
from dataclasses import dataclass
55
import sys
6+
import logging
67

78
import github
89
from github import Github
@@ -220,7 +221,7 @@ def upload_metrics(workflow_metrics, metrics_userid, api_key):
220221
"""
221222

222223
if len(workflow_metrics) == 0:
223-
print("No metrics found to upload.", file=sys.stderr)
224+
logging.info("No metrics found to upload.")
224225
return
225226

226227
metrics_batch = []
@@ -249,9 +250,7 @@ def upload_metrics(workflow_metrics, metrics_userid, api_key):
249250
)
250251

251252
if response.status_code < 200 or response.status_code >= 300:
252-
print(
253-
f"Failed to submit data to Grafana: {response.status_code}", file=sys.stderr
254-
)
253+
logging.info(f"Failed to submit data to Grafana: {response.status_code}")
255254

256255

257256
def main():
@@ -275,7 +274,7 @@ def main():
275274
current_metrics += get_sampled_workflow_metrics(github_repo)
276275

277276
upload_metrics(current_metrics, grafana_metrics_userid, grafana_api_key)
278-
print(f"Uploaded {len(current_metrics)} metrics", file=sys.stderr)
277+
logging.info(f"Uploaded {len(current_metrics)} metrics")
279278

280279
for workflow_metric in reversed(current_metrics):
281280
if isinstance(workflow_metric, JobMetrics):
@@ -287,4 +286,5 @@ def main():
287286

288287

289288
if __name__ == "__main__":
289+
logging.basicConfig(level=logging.INFO)
290290
main()

0 commit comments

Comments
 (0)