starlette-x-bugsnag

Shiny Bugsnag integration for Starlette framework


Keywords
starlette, bugsnag, asgi
License
MIT
Install
pip install starlette-x-bugsnag==0.1.4

Documentation

starlette-x-bugsnag

Shiny Bugsnag integration for Starlette framework

test codecov dependencies version pyversions black license

Scope details, local variables and installed packages will be attached to each event for ease of debugging.

Installation:

pip install starlette-x-bugsnag

Usage:

from starlette.applications import Starlette
from starlette.middleware import Middleware
from starlette.requests import Request
from starlette.responses import JSONResponse
from starlette.routing import Route

from starlette_x_bugsnag.middleware import BugsnagMiddleware


async def home(request: Request) -> JSONResponse:
    return JSONResponse({"message": "Hello world!"})


routes = [Route("/", home)]

# Using application constructor
application = Starlette(
    routes=routes, middleware=[Middleware(BugsnagMiddleware, api_key="secret")],
)

# Or using add_middleware method
application.add_middleware(BugsnagMiddleware, api_key="secret")

BugsnagMiddleware accepts same arguments as bugsnag.configure function, so you can pass additional information about your app, such as app_version.

application = Starlette(
    routes=routes,
    middleware=[
        Middleware(
            BugsnagMiddleware,
            api_key="secret",
            app_version="1.2.3",
            release_stage="production",
            project_root=None,  # Save traceback not only from the current directory
        ),
    ],
)