Skip to content

Commit

Permalink
Support missing performance data
Browse files Browse the repository at this point in the history
Its normal for some tests (eg paused, failed etc) to not have any performance data
  • Loading branch information
Jeff-SearchPilot committed Mar 4, 2024
1 parent b3f95e6 commit 36eb3bb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions status_cake_exporter/_test_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ def transform(

for i in tests:
logger.debug(f"Transforming test id: {i['id']}")
t.append(
{
test = {
"test_id": str(i["id"]),
"test_type": str(
i["test_type"]
Expand All @@ -88,12 +87,14 @@ def transform(
"test_url": i["website_url"],
"test_status_int": get_uptime_status(i["status"]),
"test_uptime_percent": str(i["uptime"]),
"test_performance": str(i["performance"]),
"maintenance_status_int": get_test_maintenance_status(
i["id"], tests_in_maintenance
),
}
)

if hasattr(i, 'performance'):
test["test_performance"]= str(i["performance"])
t.append(test)
logger.debug(f"Transformed test id: {i['id']}")

logger.debug(f"Test transformation complete. Returning {len(t)} metrics")
Expand Down Expand Up @@ -179,7 +180,8 @@ def collect(self):
)

for i in metrics:
performance_gauge.add_metric([i["test_id"]], (i["test_performance"]))
if 'test_performance' in i.keys():
performance_gauge.add_metric([i["test_id"]], (i["test_performance"]))

yield performance_gauge

Expand Down

0 comments on commit 36eb3bb

Please sign in to comment.