From ab41a4d340d527d5fd0ae176a02a7661f61d188e Mon Sep 17 00:00:00 2001 From: ayazabbas <30928485+ayazabbas@users.noreply.github.com> Date: Tue, 28 May 2024 11:26:44 +0100 Subject: [PATCH] add website link to zenduty alert (#76) * add website link to zenduty alert, add safety check in zd alert logic * lint * bump version --- pyproject.toml | 2 +- pyth_observer/dispatch.py | 4 +++- pyth_observer/event.py | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d4637ee..878fc92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ ignore_missing_imports = true [tool.poetry] name = "pyth-observer" -version = "0.2.11" +version = "0.2.12" description = "Alerts and stuff" authors = [] readme = "README.md" diff --git a/pyth_observer/dispatch.py b/pyth_observer/dispatch.py index 681e497..886e453 100644 --- a/pyth_observer/dispatch.py +++ b/pyth_observer/dispatch.py @@ -208,7 +208,9 @@ async def process_zenduty_events(self, current_time): logger.debug(f"Raising Zenduty alert {identifier}") self.open_alerts[identifier]["sent"] = True self.open_alerts[identifier]["last_alert"] = current_time.isoformat() - to_alert.append(self.zenduty_events[identifier].send()) + event = self.zenduty_events.get(identifier) + if event: + to_alert.append(event.send()) await asyncio.gather(*to_alert) for identifier in to_remove: diff --git a/pyth_observer/event.py b/pyth_observer/event.py index 301f34e..3116a5d 100644 --- a/pyth_observer/event.py +++ b/pyth_observer/event.py @@ -170,6 +170,16 @@ async def send(self): state = self.check.state() if isinstance(state, PublisherState): alert_identifier += f"-{state.publisher_name}" + symbol = ( + self.check.state().symbol.replace(".", "-").replace("/", "-").lower() + ) + cluster = ( + "solana-mainnet-beta" + if self.context["network"] == "mainnet" + else self.context["network"] + ) + publisher_key = state.public_key.key + summary += f"https://pyth.network/metrics?price-feed={symbol}&cluster={cluster}&publisher={publisher_key}\n" logger.debug(f"Sending Zenduty alert for {alert_identifier}") await send_zenduty_alert(