Flask
Looking for detailed tracing to support your microservices architecture? Check out our sister app, TelemetryHub.
Flask
Scout supports Flask 0.10+.
General instructions for a Flask app:
1. Install the scout-apm
package:
pip install scout-apm
2. Configure Scout inside your Flask app:
from scout_apm.flask import ScoutApm
# Setup a flask 'app' as normal
# Attach ScoutApm to the Flask App
ScoutApm(app)
# Scout settings
app.config["SCOUT_MONITOR"] = True
app.config["SCOUT_KEY"] = "[AVAILABLE IN THE SCOUT UI]"
app.config["SCOUT_NAME"] = "A FRIENDLY NAME FOR YOUR APP"
If you wish to configure Scout via environment variables, use SCOUT_MONITOR
, SCOUT_NAME
and SCOUT_KEY
and remove the calls to app.config
.
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 required.
3. Deploy.
It takes approximatively five minutes for your data to first appear within the Scout UI.
If your app uses flask-sqlalchemy
, see below for additional instrumentation instructions.
Flask SQLAlchemy
Instrument flask-sqlalchemy
queries by calling instrument_sqlalchemy()
on your SQLAlchemy
instance:
py from flask_sqlalchemy import SQLAlchemy
from scout_apm.flask.sqlalchemy import instrument_sqlalchemy
app = ... # Your Flask app
db = SQLAlchemy(app) instrument_sqlalchemy(db)