Flask
Looking for detailed tracing to support your microservices architecture? Check out our sister app, TelemetryHub.
Installation
The latest scout-apm
package supports Flask 0.10+.
AInstall the scout-apm
package:
pip install scout-apm
BConfigure 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
.
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.
Flask SQLAlchemy
Instrument flask-sqlalchemy
queries by calling instrument_sqlalchemy()
on your SQLAlchemy
instance:
from flask_sqlalchemy import SQLAlchemy
from scout_apm.flask.sqlalchemy import instrument_sqlalchemy
app = ... # Your Flask app
db = SQLAlchemy(app)
instrument_sqlalchemy(db)