FastAPI

Installation

Scout supports FastAPI through the Starlette instrumentation. General instructions for a FastAPI app:

AInstall the scout-apm package:

pip install scout-apm

BAttach the Scout middleware to your FastAPI app:

from fastapi import FastAPI
from scout_apm.api import Config
from scout_apm.async_.starlette import ScoutMiddleware

Config.set(
    key="[AVAILABLE IN THE SCOUT UI]",
    name="A FRIENDLY NAME FOR YOUR APP",
    monitor=True,
)
app = FastAPI()
app.add_middleware(ScoutMiddleware)

If you wish to configure Scout via environment variables, use SCOUT_MONITOR, SCOUT_NAME, and SCOUT_KEY and pass an empty dictionary to config.

Heroku Customers: If you've installed Scout via the Heroku Addon, the provisioning process automatically sets SCOUT_MONITOR and SCOUT_KEY via config vars. Only SCOUT_NAME is additionally required.

CDeploy.

It takes approximately five minutes for your data to first appear within the Scout UI.