Conversation
Lets a provider attach extra context (e.g. a link to the originating issue) to a task's data when it errors. Wired into @track, the Celery signal handlers, and the Procrastinate integration, plus Task.error() for manual reporting. A start/reset snapshot pair lets providers that read back state from elsewhere tell a fresh capture from a stale one.
Links a failed task to its Sentry issue by reading back sentry_sdk.last_event_id() rather than capturing the exception itself, since the app is assumed to already report it via its own Sentry integration. A snapshot taken when the task starts filters out stale ids left over from an unrelated earlier capture.
snopoke
marked this pull request as ready for review
August 5, 2026 11:26
Covers the Celery, Procrastinate, @track, and Task.error() entry points with a real provider, not just the low-level helpers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a way to link a failed task back to where it was actually reported — starting with Sentry, so the TaskBadger UI can eventually show a link to the originating Sentry issue.
ContextProvideris a small extension point consulted whenever a tracked task errors (@track, Celery, Procrastinate, orTask.error(exception=...)), letting a provider attach extra data.SentryContextProvideris the first implementation.Worth a closer look:
SentryContextProviderdoesn't callsentry_sdk.capture_exceptionitself — it assumes the app already reports exceptions via its own Sentry setup, and just reads backsentry_sdk.last_event_id()to avoid double-reporting the same exception. Since that's a passive read, a snapshot is taken when the task starts and compared at error time, so a stale id from some unrelated earlier capture isn't misreported as belonging to this task's error.Usage:
Failed tasks then get
data["sentry"] = {"event_id": ..., "url": "https://sentry.io/organizations/acme/issues/?query=<id>"}.sentry-sdkis an optional dependency (newsentryextra), imported lazily so it's a no-op if not installed.