The Celery integration adds support for the Celery Task Queue System.
CeleryIntegration() to your
import sentry_sdk from sentry_sdk.integrations.celery import CeleryIntegration sentry_sdk.init( dsn='https://examplePublicKey@o0.ingest.sentry.io/0', integrations=[ CeleryIntegration(), ], # Set traces_sample_rate to 1.0 to capture 100% # of transactions for performance monitoring. # We recommend adjusting this value in production, traces_sample_rate=1.0, )
Additionally, the Sentry Python SDK will set the transaction on the event to the task name, and it will improve the grouping for global Celery errors such as timeouts.
The integration will automatically report errors from all celery jobs.
Generally, make sure that the call to
init is loaded on worker startup, and not only in the module where your tasks are defined. Otherwise, the initialization happens too late and events might end up not being reported.
There are many valid ways to do this like, for example, using a signal like
worker_process_init, or by initializing the SDK in the configuration file loaded with Celery's
To verify if your SDK is initialized on worker start, you can pass
debug=True to see extra output when the SDK is initialized. If the output appears during worker startup and not only after a task has started, then it's working properly.