Sentry¶
- class chancy.plugins.sentry.SentryPlugin[source]¶
Bases:
Plugin
A plugin that sends errors to Sentry.
This plugin will send all errors that occur during job execution to Sentry, along with extended metadata about the job such as the executing worker, the queue, and the job ID.
This plugin assumes you’ve already configured sentry-sdk using
sentry_sdk.init()
at some point, to prevent conflicts with other Sentry integrations.Requires the sentry-sdk package version 2.0.0 or higher.
Usage:
pip install sentry-sdk
from chancy.plugins.sentry import SentryPlugin async with Chancy(..., plugins=[SentryPlugin()]) as chancy: pass
- async on_job_completed(*, worker: Worker, job: QueuedJob, exc: Exception | None = None, result: Any | None = None) QueuedJob [source]¶
Called after a job is completed (successfully or otherwise) and before the QueuedJob is updated in the database.
If an exception occurred during the job, exc will be the exception instance instead of
None
.The passed job is immutable - to modify it, return a new QueuedJob object with the desired changes.
- Parameters:
worker – The worker that is running the job.
job – The job that was completed.
exc – The exception that was raised, if any.
result – The result of the job, if any.
- Returns:
The job to update in the database.