← All platforms

Flask error tracking

A few routes can turn into a whole business. Keep an eye on their errors with the Sentry Flask integration and your own Telebugs server.

~/hoofnotes  python -m pip install sentry-sdk
~/hoofnotes  nvim app.py
import sentry_sdk
from flask import Flask
sentry_sdk.init(
# Copy the complete Telebugs DSN, key and path included.
dsn="YOUR_TELEBUGS_DSN",
)
app = Flask(__name__)
# Remove this test route after checking Telebugs.
@app.route("/telebugs-test")
def check_notes():
raise RuntimeError("Hello from Hoof Notes")
~/hoofnotes  flask --app app run

Space pauses or resumes. R replays. Escape shows the complete setup.

Hang on, I already use Sentry

Keep sentry-sdk. Point it at your Telebugs DSN and keep reporting errors as before. The reports go to your server; you don’t need a Sentry account.

Does it know about Flask requests?

Yes. The SDK has a Flask integration for unhandled view exceptions and request context. You don’t need to add a reporting call to every route.

What if my view catches the error?

You can still report it with sentry_sdk.capture_exception. For scripts outside Flask, the same SDK works with plain Python.