From: Zack Cerza Date: Thu, 16 Mar 2023 17:28:12 +0000 (-0600) Subject: exporter: Make JobResults a singleton X-Git-Tag: 1.2.0~118^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2df6a51d45c640b051e27a91d833269ea3df8df8;p=teuthology.git exporter: Make JobResults a singleton This should avoid "Duplicated timeseries in CollectorRegistry" errors. Signed-off-by: Zack Cerza --- diff --git a/teuthology/exporter.py b/teuthology/exporter.py index af5126c9b..f1d910da6 100644 --- a/teuthology/exporter.py +++ b/teuthology/exporter.py @@ -169,7 +169,7 @@ class Nodes(TeuthologyMetric): ) -class JobResults(TeuthologyMetric): +class _JobResults(TeuthologyMetric): def __init__(self): self.metric = Counter( "teuthology_job_results", @@ -182,6 +182,8 @@ class JobResults(TeuthologyMetric): self.metric.labels(machine_type=machine_type, status=status).inc() +JobResults = _JobResults() + NodeLockingTime = Summary( "teuthology_node_locking_duration_seconds", "Time spent waiting to lock nodes", diff --git a/teuthology/kill.py b/teuthology/kill.py index c26432a3c..2df126d9a 100755 --- a/teuthology/kill.py +++ b/teuthology/kill.py @@ -87,7 +87,7 @@ def kill_job(run_name, job_id, archive_base=None, owner=None, skip_nuke=False): owner = job_info['owner'] kill_processes(run_name, [job_info.get('pid')]) if 'machine_type' in job_info: - teuthology.exporter.JobResults().record( + teuthology.exporter.JobResults.record( job_info["machine_type"], job_info.get("status", "dead") ) diff --git a/teuthology/report.py b/teuthology/report.py index 3b4247e51..e5382133b 100644 --- a/teuthology/report.py +++ b/teuthology/report.py @@ -474,7 +474,7 @@ def push_job_info(run_name, job_id, job_info, base_uri=None): reporter.report_job(run_name, job_id, job_info) status = get_status(job_info) if status in ["pass", "fail", "dead"] and "machine_type" in job_info: - teuthology.exporter.JobResults().record(job_info["machine_type"], status) + teuthology.exporter.JobResults.record(job_info["machine_type"], status) def try_push_job_info(job_config, extra_info=None): @@ -584,7 +584,7 @@ def try_mark_run_dead(run_name): log.info("Marking job {job_id} as dead".format(job_id=job_id)) reporter.report_job(run_name, job['job_id'], dead=True) if "machine_type" in job: - teuthology.exporter.JobResults().record(job["machine_type"], job["status"]) + teuthology.exporter.JobResults.record(job["machine_type"], job["status"]) except report_exceptions: log.exception("Could not mark job as dead: {job_id}".format( job_id=job_id))