Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make failed bot startups more informative #25

Merged
merged 2 commits into from
Dec 1, 2021
Merged
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
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:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the base class for telethon errors, I don't think we can get more specific than this given all the ways we've seen this failing.

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