Skip to content

Commit 0f88050

Browse files
authored
better format DD alert text (#64)
* better format DD alert text * poetry version patch * lint fix
1 parent 74b4a9f commit 0f88050

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ignore_missing_imports = true
44

55
[tool.poetry]
66
name = "pyth-observer"
7-
version = "0.2.1"
7+
version = "0.2.2"
88
description = "Alerts and stuff"
99
authors = []
1010
readme = "README.md"

pyth_observer/check/price_feed.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def error_message(self) -> dict:
8383
distance = self.__state.latest_block_slot - self.__state.latest_trading_slot
8484
return {
8585
"msg": f"{self.__state.symbol} is offline (either non-trading/stale). Last update {distance} slots ago.",
86-
"type": "PriceFeedCheck",
86+
"type": "PriceFeedOfflineCheck",
8787
"symbol": self.__state.symbol,
8888
"latest_trading_slot": self.__state.latest_trading_slot,
8989
"block_slot": self.__state.latest_block_slot,
@@ -127,7 +127,7 @@ def run(self) -> bool:
127127
def error_message(self) -> dict:
128128
return {
129129
"msg": f"{self.__state.symbol} is too far from Coingecko's price.",
130-
"type": "PriceFeedCheck",
130+
"type": "PriceFeedCoinGeckoCheck",
131131
"symbol": self.__state.symbol,
132132
"pyth_price": self.__state.price_aggregate,
133133
"coingecko_price": self.__state.coingecko_price,
@@ -157,7 +157,7 @@ def run(self) -> bool:
157157
def error_message(self) -> dict:
158158
return {
159159
"msg": f"{self.__state.symbol} confidence interval is too low.",
160-
"type": "PriceFeedCheck",
160+
"type": "PriceFeedConfidenceIntervalCheck",
161161
"symbol": self.__state.symbol,
162162
"confidence_interval": self.__state.confidence_interval_aggregate,
163163
}
@@ -213,7 +213,7 @@ def error_message(self) -> dict:
213213

214214
return {
215215
"msg": f"{self.__state.symbol} isn't online at the price service.",
216-
"type": "PriceFeedCheck",
216+
"type": "PriceFeedCrossChainOnlineCheck",
217217
"symbol": self.__state.symbol,
218218
"last_publish_time": publish_time.format("YYYY-MM-DD HH:mm:ss ZZ"),
219219
}
@@ -273,7 +273,7 @@ def error_message(self) -> dict:
273273
)
274274
return {
275275
"msg": f"{self.__state.symbol} is too far at the price service.",
276-
"type": "PriceFeedCheck",
276+
"type": "PriceFeedCrossChainDeviationCheck",
277277
"symbol": self.__state.symbol,
278278
"price": self.__state.price_aggregate,
279279
"price_at_price_service": price,

pyth_observer/check/publisher.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def error_message(self) -> dict:
8282
intervals_away = abs(diff / self.__state.confidence_interval_aggregate)
8383
return {
8484
"msg": f"{self.__state.publisher_name} price is {intervals_away} times away from confidence.",
85-
"type": "PublisherCheck",
85+
"type": "PublisherWithinAggregateConfidenceCheck",
8686
"publisher": self.__state.publisher_name,
8787
"symbol": self.__state.symbol,
8888
"publisher_price": f"{self.__state.price} ± {self.__state.confidence_interval}",
@@ -118,7 +118,7 @@ def run(self) -> bool:
118118
def error_message(self) -> dict:
119119
return {
120120
"msg": f"{self.__state.publisher_name} confidence interval is too tight.",
121-
"type": "PublisherCheck",
121+
"type": "PublisherConfidenceIntervalCheck",
122122
"publisher": self.__state.publisher_name,
123123
"symbol": self.__state.symbol,
124124
"price": self.__state.price,
@@ -153,7 +153,7 @@ def error_message(self) -> dict:
153153
distance = self.__state.latest_block_slot - self.__state.slot
154154
return {
155155
"msg": f"{self.__state.publisher_name} hasn't published recently for {distance} slots.",
156-
"type": "PublisherCheck",
156+
"type": "PublisherOfflineCheck",
157157
"publisher": self.__state.publisher_name,
158158
"symbol": self.__state.symbol,
159159
"publisher_slot": self.__state.slot,
@@ -201,7 +201,7 @@ def error_message(self) -> dict:
201201
deviation = (self.ci_adjusted_price_diff() / self.__state.price_aggregate) * 100
202202
return {
203203
"msg": f"{self.__state.publisher_name} price is too far from aggregate price.",
204-
"type": "PublisherCheck",
204+
"type": "PublisherPriceCheck",
205205
"publisher": self.__state.publisher_name,
206206
"symbol": self.__state.symbol,
207207
"publisher_price": f"{self.__state.price} ± {self.__state.confidence_interval}",

pyth_observer/event.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import os
32
from typing import Dict, Protocol, TypedDict, cast
43

@@ -39,7 +38,11 @@ def __init__(self, check: Check, context: Context):
3938
async def send(self):
4039
# Publisher checks expect the key -> name mapping of publishers when
4140
# generating the error title/message.
42-
event = self.check.error_message()
41+
event_content = self.check.error_message()
42+
event_title = event_content["msg"]
43+
event_text = ""
44+
for key, value in event_content:
45+
event_text += f"{key}: {value}\n"
4346

4447
# An example is: PriceFeedOfflineCheck-Crypto.AAVE/USD
4548
aggregation_key = f"{self.check.__class__.__name__}-{self.check.state().symbol}"
@@ -51,8 +54,8 @@ async def send(self):
5154

5255
event = EventCreateRequest(
5356
aggregation_key=aggregation_key,
54-
title=event["msg"],
55-
text=json.dumps(event),
57+
title=event_title,
58+
text=event_text,
5659
tags=[
5760
"service:observer",
5861
f"network:{self.context['network']}",

0 commit comments

Comments
 (0)