diff --git a/pyth_observer/__init__.py b/pyth_observer/__init__.py index a538d2b..36d41ad 100644 --- a/pyth_observer/__init__.py +++ b/pyth_observer/__init__.py @@ -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"], @@ -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): diff --git a/pyth_observer/cli.py b/pyth_observer/cli.py index 4f129aa..faede7b 100644 --- a/pyth_observer/cli.py +++ b/pyth_observer/cli.py @@ -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")) @@ -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)) diff --git a/pyth_observer/dispatch.py b/pyth_observer/dispatch.py index 97d9b84..f6d0171 100644 --- a/pyth_observer/dispatch.py +++ b/pyth_observer/dispatch.py @@ -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() @@ -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"]: diff --git a/pyth_observer/metrics.py b/pyth_observer/metrics.py index 975cc6a..8d331f9 100644 --- a/pyth_observer/metrics.py +++ b/pyth_observer/metrics.py @@ -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( { @@ -165,7 +163,6 @@ def set_observer_info( ) ), "event_handlers": ",".join(config.get("events", [])), - "telegram_enabled": str(int(telegram_enabled)), } )