Skip to content
bliptracedocs

Install an SDK

FastAPI / Starlette

ASGI middleware that reports unhandled exceptions from FastAPI or any Starlette app, then re-raises them.

On this page

The FastAPI adapter is ASGI middleware. It catches unhandled exceptions, sends them with the request context and re-raises, so your normal error handling still runs. It works with any Starlette app.

Install from GitHub. Not on PyPI yet. Sources: bliptrace-python, bliptrace-fastapi.

Install

pip install "g8scope @ git+https://github.com/bliptrace/bliptrace-python" \
            "g8scope-fastapi @ git+https://github.com/bliptrace/bliptrace-fastapi"

Use it

import os
from fastapi import FastAPI
from g8scope_fastapi import G8ScopeMiddleware

app = FastAPI()
app.add_middleware(
    G8ScopeMiddleware,
    key=os.environ.get("BLIPTRACE_KEY"),
    endpoint="https://ingest.bliptrace.com",
    environment="production",
)

The helper add_g8scope(app, key=..., environment=...) does the same. Every keyword is passed to the Python SDK’s Config (release, base_path, enabled, ignore_exceptions, scrub_keys, timeout).

Prefer an exception handler? app.add_exception_handler(Exception, g8scope_exception_handler(client)) with a g8scope.Client.

Request context includes the method, URL and headers without authorization and cookie.

Documentation