]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
exporter: Make JobResults a singleton
authorZack Cerza <zack@redhat.com>
Thu, 16 Mar 2023 17:28:12 +0000 (11:28 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 22 Mar 2023 15:52:10 +0000 (09:52 -0600)
This should avoid "Duplicated timeseries in CollectorRegistry" errors.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/exporter.py
teuthology/kill.py
teuthology/report.py

index af5126c9b49cdfa1475c84c6a518d4f746f6a512..f1d910da64419af1c2b2ff9c7c5c644825af334a 100644 (file)
@@ -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",
index c26432a3caec009c06b8570a8b8a448fffbe0592..2df126d9a856371651a651d13a89ea4fdb4855ce 100755 (executable)
@@ -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")
         )
index 3b4247e517f452df0c0debc6779ae5bbcbb190d0..e5382133b5a8a57d386b63848a8a6946281f85fd 100644 (file)
@@ -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))