Other Libraries
Bottle
General instructions for a Bottle app:
1. Install the scout-apm
package:
pip install scout-apm
2. Add Scout to your Bottle config:
from scout_apm.bottle import ScoutPlugin
app = bottle.default_app()
app.config.update({
"scout.name": "YOUR_APP_NAME",
"scout.key": "YOUR_KEY",
"scout.monitor": True,
})
scout = ScoutPlugin()
bottle.install(scout)
If you wish to configure Scout via environment variables, use SCOUT_MONITOR
, SCOUT_NAME
and SCOUT_KEY
and remove the call to app.config.update
.
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.
CherryPy
Scout supports CherryPy 18.0.0+.
General instructions for a CherryPy app:
1. Install the scout-apm
package:
pip install scout-apm
2. Attach the Scout plugin to your app:
import cherrypy
from scout_apm.api import Config
from scout_apm.cherrypy import ScoutPlugin
class Views(object):
@cherrypy.expose
def index(self):
return "Hi"
app = cherrypy.Application(Views(), "/")
Config.set(
key="[AVAILABLE IN THE SCOUT UI]",
monitor=True,
name="A FRIENDLY NAME FOR YOUR APP",
)
scout_plugin = ScoutPlugin(cherrypy.engine)
scout_plugin.subscribe()
If you wish to configure Scout via environment variables, use SCOUT_MONITOR
, SCOUT_NAME
and SCOUT_KEY
and remove the call to Config.set
.
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.
Dash
Plotly Dash is built on top of Flask. Therefore you should use the Scout Flask integration with the underlying Flask application object. For example:
import dash
from scout_apm.flask import ScoutApm
app = dash.Dash("myapp")
app.config.suppress_callback_exceptions = True
flask_app = app.server
# Setup as per Flask integration
ScoutApm(flask_app)
flask_app.config["SCOUT_NAME"] = "A FRIENDLY NAME FOR YOUR APP"
For full instructions, see the Flask integration.
Dramatiq
cout supports Dramatiq 1.0+. Add the following to instrument Dramatiq workers:
1. Install the scout-apm
package:
pip install scout-apm
2. Add Scout to your Dramatiq broker:
import dramatiq
from dramatiq.brokers.rabbitmq import RabbitmqBroker
from scout_apm.dramatiq import ScoutMiddleware
from scout_apm.api import Config
broker = RabbitmqBroker()
broker.add_middleware(ScoutMiddleware(), before=broker.middleware[0].__class__)
Config.set(
key="[AVAILABLE IN THE SCOUT UI]",
name="Same as Web App Name",
monitor=True,
)
If you wish to configure Scout via environment variables, use SCOUT_MONITOR
, SCOUT_NAME
and SCOUT_KEY
instead of calling Config.set
.
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.
Tasks will appear in the “Background Jobs” area of the Scout UI.
Falcon
Scout supports Falcon 2.0+. General instructions for a Falcon app:
1. Install the scout-apm
package:
pip install scout-apm
2. Attach the Scout middleware to your Falcon app:
import falcon
from scout_apm.falcon import ScoutMiddleware
scout_middleware = ScoutMiddleware(config={
"key": "[AVAILABLE IN THE SCOUT UI]",
"monitor": True,
"name": "A FRIENDLY NAME FOR YOUR APP",
})
api = falcon.API(middleware=[ScoutMiddleware()])
# Required for accessing extra per-request information
scout_middleware.set_api(api)
If you wish to configure Scout via environment variables, use SCOUT_MONITOR
, SCOUT_NAME
and SCOUT_KEY
and pass an empty dictionary to 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.
Huey
Scout supports Huey 2.0+.
Add the following to instrument your Huey application:
1. Install the scout-apm
package:
pip install scout-apm
2. If you are using Huey’s Django integration, you only need to set up the Django integration. Your Huey instance will be automatically instrumented.
If you’re using Huey outside of the Django integration, add Scout to your Huey instance:
from huey import SqliteHuey
from scout_apm.api import Config
from scout_apm.huey import attach_scout
broker = SqliteHuey()
Config.set(
monitor=True,
name="A FRIENDLY NAME FOR YOUR APP",
key="[AVAILABLE IN THE SCOUT UI]",
)
attach_scout(huey)
If you wish to configure Scout via environment variables, use SCOUT_MONITOR
, SCOUT_NAME
and SCOUT_KEY
instead of calling Config.set()
.
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.
Tasks will appear in the “Background Jobs” area of the Scout UI.
Hug
Scout supports Hug 2.5.1+. Hug is based on Falcon so a Falcon version supported by our integration is also needed.
General instructions for a Hug app:
1. Install the scout-apm
package:
pip install scout-apm
2. Configure Scout inside your Hug app:
from scout_apm.hug import integrate_scout
# Setup your Hug endpoints as usual
@hug.get("/")
def home():
return "Welcome home."
# Integrate scout with the Hug application for this module
integrate_scout(
__name__,
config={
"key": "[AVAILABLE IN THE SCOUT UI]",
"monitor": True,
"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 entries in 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.
Nameko
General instructions for a Nameko app:
1. Install the scout-apm
package:
pip install scout-apm
2. Configure scout once in the root of your app, and add a ScoutReporter
to each Nameko service:
from scout_apm.api import Config
from scout_apm.nameko import ScoutReporter
Config.set(
key="[AVAILABLE IN THE SCOUT UI]",
name="A FRIENDLY NAME FOR YOUR APP",
monitor=True,
)
class Service(object):
name = "myservice"
scout = ScoutReporter()
@http("GET", "/")
def home(self, request):
return "Welcome home."
If you wish to configure Scout via environment variables, use SCOUT_MONITOR
, SCOUT_NAME
and SCOUT_KEY
and remove the call to Config.set
.
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.
Pyramid
General instructions for a Pyramid app:
1. Install the scout-apm
package:
pip install scout-apm
2. Add Scout to your Pyramid config:
import scout_apm.pyramid
if __name__ == "__main__":
with Configurator() as config:
config.add_settings(
SCOUT_KEY="[AVAILABLE IN THE SCOUT UI]",
SCOUT_MONITOR=True,
SCOUT_NAME="A FRIENDLY NAME FOR YOUR APP"
)
config.include("scout_apm.pyramid")
# Rest of your config...
If you wish to configure Scout via environment variables, use SCOUT_MONITOR
, SCOUT_NAME
and SCOUT_KEY
and remove the call to config.add_settings
.
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.
RQ
Scout supports RQ 1.0+.
Do the following to instrument your RQ jobs:
1. Install the scout-apm
package:
pip install scout-apm
2. Use the Scout RQ worker class.
If you’re using RQ directly, you can pass the --worker-class
argument the worker command:
rq worker --job-class scout_apm.rq.Worker myqueue
If you’re using the RQ Heroku pattern, you can change your code to use the scout_apm.rq.HerokuWorker
class:
from scout_apm.rq import HerokuWorker as Worker
If you’re using Django-RQ, instead use the custom worker setting to point to our custom Worker class:
RQ = {
"WORKER_CLASS": "scout_apm.rq.Worker",
}
If you’re using your own Worker
sub class already, you can subclass our Worker
class:
from scout_apm.rq import Worker
class MyWorker(Worker):
# your custom behaviour here
pass
Or if you’re combining one or more other Worker
classes, you can add our mixin class scout_apm.rq.WorkerMixin
:
from some.other.rq.extension import CustomWorker
from scout_apm.rq import WorkerMixin
class MyWorker(WorkerMixin, CustomWorker):
pass
3. Configure Scout.
If you’re using Django-RQ, ensure you have the Django integration installed, and this is handled for you.
If you’re using RQ directly, create a config file for it that runs the Scout API’s Config.set()
:
from scout_apm.api import Config
Config.set(
key="YOUR_SCOUT_KEY",
name="Same as Web App Name",
monitor=True,
)
Pass the config file to -c
argument to the worker command, as per the documentation.
If you wish to configure Scout via environment variables, you don’t need a config file. Set SCOUT_KEY
, SCOUT_NAME
and SCOUT_MONITOR
instead.
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.
4. Deploy.
It takes approximatively five minutes for your data to first appear within the Scout UI.
Tasks will appear in the “Background Jobs” area of the Scout UI.
Starlette
Scout supports Starlette 0.12+. General instructions for a Starlette app:
1. Install the scout-apm
package:
pip install scout-apm
2. Configure Scout and attach its middleware to your Starlette app:
from scout_apm.api import Config
from scout_apm.async_.starlette import ScoutMiddleware
from starlette.applications import Starlette
from starlette.middleware import Middleware
Config.set(
key="[AVAILABLE IN THE SCOUT UI]",
name="A FRIENDLY NAME FOR YOUR APP",
monitor=True,
)
middleware = [
# Should be *first* in your stack, so it's the outermost and can
# track all requests
Middleware(ScoutMiddleware),
]
app = Starlette(middleware=middleware)
If you’re using Starlette <0.13, which refactored the middleware API, instead use app.add_middleware(ScoutMiddleware)
. Make sure it’s the last call to add_middleware()
so that Scout is the outermost middleware.
If you wish to configure Scout via environment variables, use SCOUT_MONITOR
, SCOUT_NAME
and SCOUT_KEY
and remove the call to Config.set
.
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.