From 3c80a4afb12622a6540ea7bc8481f5bb502d7f57 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Wed, 8 Jan 2025 16:31:57 +0900 Subject: [PATCH 1/2] fix: re-alert only on the hour --- pyth_observer/dispatch.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pyth_observer/dispatch.py b/pyth_observer/dispatch.py index d34036c..de5fb73 100644 --- a/pyth_observer/dispatch.py +++ b/pyth_observer/dispatch.py @@ -197,13 +197,16 @@ async def process_zenduty_events(self, current_time): to_remove.append(identifier) # Raise alert if failed > $threshold times within the last 5m window # or if already alerted and not yet resolved. - # Re-alert every 5 minutes but not more often. + # Re-alert at the start of each hour but not more often. elif ( info["failures"] >= alert_threshold or (info["sent"] and not resolved) ) and ( - not info.get("last_alert") - or current_time - datetime.fromisoformat(info["last_alert"]) - > timedelta(minutes=5) + not info.get("last_alert") # First alert - send immediately + or ( # Subsequent alerts - send at the start of each hour + current_time - datetime.fromisoformat(info["last_alert"]) + > timedelta(minutes=5) + and current_time.minute == 0 # Only alert at the start of each hour + ) ): logger.debug(f"Raising Zenduty alert {identifier}") self.open_alerts[identifier]["sent"] = True From 0a53dc2dc5c0dd80f553f076452a88ed16cde1aa Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Thu, 9 Jan 2025 16:58:19 +0900 Subject: [PATCH 2/2] bump --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0b0cf64..2523f04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ ignore_missing_imports = true [tool.poetry] name = "pyth-observer" -version = "0.3.2" +version = "0.3.3" description = "Alerts and stuff" authors = [] readme = "README.md"