From aa60711b7cc70d32435b296248dbf24db6fb93f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylvain=20Veyri=C3=A9?= Date: Thu, 24 May 2018 11:13:53 +0200 Subject: [PATCH 1/2] Fix None case --- jenkins_exporter/jenkins_exporter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jenkins_exporter/jenkins_exporter.py b/jenkins_exporter/jenkins_exporter.py index 3ab8176..2eaf234 100755 --- a/jenkins_exporter/jenkins_exporter.py +++ b/jenkins_exporter/jenkins_exporter.py @@ -50,7 +50,10 @@ def collect(self): name = job['name'] for s in statuses: # If there's a null result, we want to export zeros. - status = job[s] or {} + if s in job and job[s]: + status=job[s] + else: + status={} metrics[s]['number'].add_metric([name], status.get('number', 0)) metrics[s]['duration'].add_metric([name], status.get('duration', 0) / 1000.0) metrics[s]['timestamp'].add_metric([name], status.get('timestamp', 0) / 1000.0) From a7edf15a41521296bd699edba528969eb5640e6d Mon Sep 17 00:00:00 2001 From: yngwiewang <64290793+yngwiewang@users.noreply.github.com> Date: Sun, 3 Oct 2021 16:52:44 +0800 Subject: [PATCH 2/2] fix a typo --- csv/query_csv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csv/query_csv.py b/csv/query_csv.py index f50c766..43355f2 100644 --- a/csv/query_csv.py +++ b/csv/query_csv.py @@ -27,7 +27,7 @@ # Write the header, writer.writerow(['name', 'timestamp', 'value'] + labelnames) -# Write the sanples. +# Write the samples. for result in results: l = [result['metric'].get('__name__', '')] + result['value'] for label in labelnames: