Lightrun for Celery¶
To run Celery with the Lightrun agent, follow these steps:
- In your application folder, install the Python agent by running
python -m pip install lightrun
. - Add the following to the
.py
file where Celery is initiated (where there is a call toCelery()
, usuallycelery.py
).from celery.signals import task_prerun @task_prerun.connect() def task_prerun(**kwargs): try: import lightrun lightrun.enable(company="<COMPANY_NAME>" , company_key="<COMPANY_SECRET>") except ImportError as e: print("Error importing Lightrun: ", e)
- Run your Celery processes as normal.
Note
The Celery task_prerun
signal dispatch before a task is executed. This signal ensures that a Lightrun agent has been created before the Celery task is executed.
Imp
You might need to provide the lightrun_extra_class_path
configuration parameter to ensure that Lightrun is able to index all the functions.
Last update: November 19, 2024