Celery

Celery

Scout supports Celery 3.1+.

Add the following to instrument Celery workers:

1. Install the scout-apm package:

pip install scout-apm

2. Configure Scout in your Celery application file:

import scout_apm.celery
from scout_apm.api import Config
from celery import Celery

app = Celery('tasks', backend='redis://localhost', broker='redis://localhost')

# If you are using app.config_from_object() to point to your Django settings
# and have configured Scout there, this is not necessary:
Config.set(
    key="[AVAILABLE IN THE SCOUT UI]",
    name="Same as Web App Name",
    monitor=True,
    # If you'd like to utilize Error Monitoring:
    errors_enabled=True,
) 
scout_apm.celery.install(app)

The app argument is optional and was added in version 2.12.0, but you should provide it for complete instrumentation.

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.