Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pyth_observer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ def __init__(
config: Dict[str, Any],
publishers: Dict[str, Publisher],
coingecko_mapping: Dict[str, Symbol],
disable_telegram: bool = False,
):
self.config = config
self.dispatch = Dispatch(config, publishers, disable_telegram)
self.dispatch = Dispatch(config, publishers)
self.publishers = publishers
self.pyth_client = PythClient(
solana_endpoint=config["network"]["http_endpoint"],
Expand All @@ -76,7 +75,6 @@ def __init__(
metrics.set_observer_info(
network=config["network"]["name"],
config=config,
telegram_enabled=not disable_telegram,
)

async def run(self):
Expand Down
15 changes: 6 additions & 9 deletions pyth_observer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,7 @@
envvar="PROMETHEUS_PORT",
default="9001",
)
@click.option(
"--disable-telegram",
help="Disable sending Telegram notifications",
envvar="DISABLE_TELEGRAM",
is_flag=True,
default=False,
)
def run(config, publishers, coingecko_mapping, prometheus_port, disable_telegram):
def run(config, publishers, coingecko_mapping, prometheus_port):
config_ = yaml.safe_load(open(config, "r"))
# Load publishers YAML file and convert to dictionary of Publisher instances
publishers_raw = yaml.safe_load(open(publishers, "r"))
Expand All @@ -61,7 +54,11 @@ def run(config, publishers, coingecko_mapping, prometheus_port, disable_telegram
for publisher in publishers_raw
}
coingecko_mapping_ = yaml.safe_load(open(coingecko_mapping, "r"))
observer = Observer(config_, publishers_, coingecko_mapping_, disable_telegram)
observer = Observer(
config_,
publishers_,
coingecko_mapping_,
)

start_http_server(int(prometheus_port))

Expand Down
5 changes: 1 addition & 4 deletions pyth_observer/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ class Dispatch:
notifiers for the checks that failed.
"""

def __init__(self, config, publishers, disable_telegram=False):
def __init__(self, config, publishers):
self.config = config
self.publishers = publishers
self.disable_telegram = disable_telegram
if "ZendutyEvent" in self.config["events"]:
self.open_alerts_file = os.environ["OPEN_ALERTS_FILE"]
self.open_alerts = self.load_alerts()
Expand Down Expand Up @@ -68,8 +67,6 @@ async def run(self, states: List[State]):
current_time = datetime.now()
for check in failed_checks:
for event_type in self.config["events"]:
if event_type == "TelegramEvent" and self.disable_telegram:
continue
event: Event = globals()[event_type](check, context)

if event_type in ["ZendutyEvent", "TelegramEvent"]:
Expand Down
5 changes: 1 addition & 4 deletions pyth_observer/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ def __init__(self, registry: CollectorRegistry = REGISTRY):
registry=registry,
)

def set_observer_info(
self, network: str, config: Dict[str, Any], telegram_enabled: bool = False
):
def set_observer_info(self, network: str, config: Dict[str, Any]):
"""Set static information about the observer instance."""
self.observer_info.info(
{
Expand All @@ -165,7 +163,6 @@ def set_observer_info(
)
),
"event_handlers": ",".join(config.get("events", [])),
"telegram_enabled": str(int(telegram_enabled)),
}
)

Expand Down