Skip to main content

Add your description here

Project description

devalerts (throwaway prototype)

Русская версия

Send unhandled Python exceptions straight to a Telegram chat. No backend, no account, no database — just your own bot token.

Install

uv add git+https://github.com/<you>/<repo>.git

(or pip install git+https://github.com/<you>/<repo>.git if you're not using uv)

Usage

  1. Create a bot with @BotFather and get its token.
  2. Message your bot once (or add it to a group) so it's allowed to message you back.
  3. Get your chat id — message @userinfobot, or call https://api.telegram.org/bot<TOKEN>/getUpdates after step 2 and read message.chat.id.
  4. In your app, as early as possible:
import devalerts

devalerts.init(bot_token="123456:ABC-DEF...", chat_id=123456789)

That's it — any unhandled exception (including ones raised in threads) now also lands in your Telegram chat.

Grouping, rate limiting, and the dashboard

Exceptions are grouped by fingerprint (exception type + file + line where it was raised) in a local SQLite file (~/.devalerts/state.db). Each group sends at most one Telegram message per rate_limit_seconds (default 300); repeats inside that window are counted but not sent, and the next message for that group says how many were skipped. Old groups (untouched for 7 days) are pruned automatically. Configure the window via init():

devalerts.init(bot_token="...", chat_id=123456789, rate_limit_seconds=60)

See what's grouped and what's currently rate-limited:

uv run devalerts dashboard

Manually reporting a caught exception

try:
    risky_call()
except Exception:
    devalerts.report()  # sends the currently-handled exception

or:

with devalerts.capture():
    risky_call()  # reports on exception, then re-raises

capture also works as a decorator, so you don't need to touch a function's body at all:

@devalerts.capture()
def risky_call():
    ...

FastAPI / Starlette / any ASGI app

init()'s excepthook won't see request errors — the framework already catches them internally to return a 500 response, so nothing "unhandled" ever reaches the process. Use the ASGI middleware instead:

app.add_middleware(devalerts.ASGIMiddleware)

Only exceptions that actually escape as server errors get reported — routing 404s and raised HTTPExceptions are already turned into responses by the framework before the middleware sees them.

What this does NOT do (by design — it's a throwaway prototype)

  • Grouping/rate limiting is local and in-process only (SQLite file, no server) — the dashboard is a CLI table, not a web UI.
  • No backend, no accounts — each user runs their own bot.
  • Basic secret redaction only (a few common token patterns) — do not rely on this for sensitive production data.
  • No automated test suite — verified manually during implementation only.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

devalerts-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

devalerts-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file devalerts-0.1.0.tar.gz.

File metadata

  • Download URL: devalerts-0.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for devalerts-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3531abb8d4003fe072629682b3a1c51d148f34e6c240d37f62c98abf65c116ed
MD5 0f7fb722930b7017a885cef459e17135
BLAKE2b-256 7f07fb46760192bd578eeb2bd93ea85702d40701422a9324e273657c8ef64396

See more details on using hashes here.

File details

Details for the file devalerts-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: devalerts-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for devalerts-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1446f1d30b8728465a9f7e40e220b879e62d71f722f40edd683b98119f8cc9e9
MD5 215495ee30b93bf73b31a7ad3690b04f
BLAKE2b-256 dbd321c1b082ba51686fd4a5ffed416d6546dbfc8afbd7e481f8db3e50e38b5d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page