The Flask adapter listens to Flask’s got_request_exception signal and sends each unhandled exception with the request context. Your app’s own error handling carries on unchanged.
Install from GitHub. Not on PyPI yet. Sources: bliptrace-python, bliptrace-flask.
Install
pip install "g8scope @ git+https://github.com/bliptrace/bliptrace-python" \
"g8scope-flask @ git+https://github.com/bliptrace/bliptrace-flask"
Use it
import os
from flask import Flask
from g8scope_flask import G8Scope
app = Flask(__name__)
app.config.update(
BLIPTRACE_KEY=os.environ.get("BLIPTRACE_KEY"),
BLIPTRACE_ENDPOINT="https://ingest.bliptrace.com",
BLIPTRACE_ENVIRONMENT="production",
BLIPTRACE_RELEASE="1.4.2",
BLIPTRACE_BASE_PATH="/srv/app",
)
G8Scope(app)
With an application factory, create g8 = G8Scope() once and call g8.init_app(app) inside the factory. Keyword arguments (G8Scope(app, key="...")) win over app.config.
| Config key | |
|---|---|
BLIPTRACE_KEY |
Nothing is sent without it |
BLIPTRACE_ENDPOINT |
https://ingest.bliptrace.com |
BLIPTRACE_ENVIRONMENT, BLIPTRACE_RELEASE |
Labels |
BLIPTRACE_TIMEOUT, BLIPTRACE_MAX_FRAMES, BLIPTRACE_MAX_MESSAGE |
Limits |
BLIPTRACE_IGNORE_EXCEPTIONS, BLIPTRACE_SCRUB_KEYS |
Lists |
BLIPTRACE_BASE_PATH |
Project root for in-app frames |
BLIPTRACE_ENABLED |
False turns capture off |
Report a handled exception
g8 = app.extensions["g8scope"]
try:
risky()
except Exception as exc:
g8.capture_exception(exc, context={"custom": {"user_id": 42}})
The authorization, cookie, set-cookie and proxy-authorization headers are removed before sending.