Skip to content

Commit

Permalink
Merge pull request #25 from vector-im/tadzik/bot-startup-metrics
Browse files Browse the repository at this point in the history
Make failed bot startups more informative
  • Loading branch information
tadzik authored Dec 1, 2021
2 parents fa3e995 + d2c9acc commit e032da7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mautrix_telegram/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import Dict, Any
import asyncio

import telethon
from telethon import __version__ as __telethon_version__
from alchemysession import AlchemySessionContainer

Expand Down Expand Up @@ -48,6 +49,7 @@
METRIC_ACTIVE_PUPPETS = Gauge('bridge_active_puppets_total', 'Number of active Telegram users bridged into Matrix')
METRIC_BLOCKING = Gauge('bridge_blocked', 'Is the bridge currently blocking messages')
METRIC_AS_CONNECTIONS = Gauge('bridge_as_connections', 'Number of active/available TCP connections in Appservice\'s pool', ['status'])
METRIC_BOT_STARTUP_OK = Gauge('bridge_bot_startup_ok', 'Whether or not the configured Telegram started up correctly')

class TelegramBridge(Bridge):
module = "mautrix_telegram"
Expand Down Expand Up @@ -117,8 +119,10 @@ async def start(self) -> None:
if self.bot:
try:
await self.bot.start()
except Exception as e:
METRIC_BOT_STARTUP_OK.set(1)
except telethon.errors.RPCError as e:
self.log.error(f"Failed to start bot: {e}")
METRIC_BOT_STARTUP_OK.set(0)

semaphore = None
concurrency = self.config['telegram.connection.concurrent_connections_startup']
Expand Down

0 comments on commit e032da7

Please sign in to comment.