feat(taskworker): capture task exception context via TaskErrorCaptureHook#114009
feat(taskworker): capture task exception context via TaskErrorCaptureHook#114009s-starostin wants to merge 1 commit intogetsentry:masterfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fef5aa7. Configure here.
fef5aa7 to
c047ecd
Compare
|
Real-world motivation: without this change, investigating task failures can require manually reproducing the task on a worker just to see the actual exception. With this the worker emits a structured single-line failure log and taskbroker receives/logs the exception context end-to-end. |
The workers already capture sentry errors for failures. |


Summary
Add a sentry-side
TaskErrorCaptureHookfor taskworker that:TaskErrorenvelope to taskbroker-client for broker-side loggingDependencies
Depends on:
This PR also requires a released
taskbroker-clientversion that includes:error_hookTaskErrorChanges
Worker hook
TaskErrorCaptureHookinsrc/sentry/taskworker/adapters.pytask_idtasknamenamespaceexception_typeexception_messageroot_cause_typeroot_cause_messageTaskErrorRuntime wiring
TaskErrorCaptureHook()intoTaskbrokerApp(...)insrc/sentry/taskworker/runtime.pyWhy
This makes task failures visible and searchable in three places at once:
It also keeps worker stdout clean and parseable for log collectors.
Logging behavior
Expected worker log shape:
taskworker.task_failed task_id="..." taskname="..." namespace="..." exception_type="..." exception_message="..." root_cause_type="..." root_cause_message="..."Tests
raise ... from Nonerespects suppressed contextLocal validation
Validated locally with a deliberately crashing task:
taskworker.task_failedtask reported failureFollow-up
Once the companion
taskbroker-clientrelease is published,pyproject.tomlshould be bumped to that released version before merge.Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.