Make worker errors visible off-host by reporting them to Sentry#159
Make worker errors visible off-host by reporting them to Sentry#159mihow wants to merge 1 commit into
Conversation
The Antenna worker logs errors through structlog, which does not route through the stdlib logging module, so Sentry's logging integration never sees them. A worker that fails every job (for example after a GPU licensing problem on the host) reports nothing off-host and the failure is only visible in the local log file. Capture exceptions explicitly at the two swallow points: the per-job handler in the claim loop and the per-batch handler in task processing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DkHC7gGrP9sumqawjHLeLP
📝 WalkthroughWalkthroughThe worker now imports Sentry and captures exceptions in both job-level and batch-level error handlers before continuing existing logging and error-response behavior. ChangesSentry exception reporting
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
trapdata/antenna/worker.py (1)
120-123: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for both Sentry capture paths.
The supplied worker tests verify Antenna error responses, but do not assert that job-level and batch-level exceptions are reported to Sentry. Mock
sentry_sdk.capture_exceptionand verify each handler invokes it once while preserving the existing response behavior.Also applies to: 367-369
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@trapdata/antenna/worker.py` around lines 120 - 123, Add regression tests for both the job-level and batch-level exception handlers in the worker, mocking sentry_sdk.capture_exception and asserting each handler calls it exactly once with the raised exception while preserving the existing Antenna error responses.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@trapdata/antenna/worker.py`:
- Around line 120-123: Add regression tests for both the job-level and
batch-level exception handlers in the worker, mocking
sentry_sdk.capture_exception and asserting each handler calls it exactly once
with the raised exception while preserving the existing Antenna error responses.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 09a402a8-546c-4eb4-bca9-24cd70a6ed60
📒 Files selected for processing (1)
trapdata/antenna/worker.py
Summary
When the Antenna worker fails to process a job, the error currently goes only to the log file on the worker machine itself. Nobody sees it unless they SSH in and read the log. In a recent production incident, a GPU licensing problem on a worker host caused every ML job to fail for several days before anyone noticed, because the failures were invisible from anywhere but the machine.
This change reports those errors to Sentry, where the team already monitors the other AMI services, so worker failures show up off-host within minutes instead of days.
List of Changes
Technical note
The worker logs through structlog, which does not route records through the stdlib
loggingmodule. Sentry's default logging integration only listens to stdlib logging, sologger.error(...)calls never reached Sentry even thoughsentry_sdk.init()runs at import time. The fix is an explicitsentry_sdk.capture_exception(e)at the two points where exceptions are caught and swallowed.🤖 Generated with Claude Code
https://claude.ai/code/session_01DkHC7gGrP9sumqawjHLeLP
Summary by CodeRabbit