Add self-contained error tracking system#21
Merged
Conversation
Implements comprehensive error tracking for application-level errors with deduplication, aggregation, and admin UI workflow. ## Core Features - **Error Capture Service**: Fingerprints errors by class + normalized message, deduplicates by fingerprint, increments occurrence counts - **Async Background Job**: Non-blocking error capture via Solid Queue - **Database Model**: Stores error class, message, backtrace, context, occurrence count, timestamps, and resolution status - **Admin UI**: Three-tab view (Unresolved/Resolved/All) with pagination, detail views with backtrace highlighting, resolve/unresolve actions - **Application Integration**: Captures errors from controllers (production only) and background jobs (excluding DispatchJob operational errors) - **Maintenance**: Rake task for cleanup of resolved errors older than 30 days ## Implementation Details - Fingerprinting normalizes IDs, UUIDs, hex addresses, temp paths - Backtrace cleaned of gem paths, limited to 50 lines - Context sanitized (removes passwords/tokens, truncates at 10KB) - Defensive error handling prevents capture failures from breaking app - Job discard_on prevents infinite retry loops - Available at `/errors` path with HTTP Basic Auth ## Database - Migration adds error_records table with indexes on fingerprint, resolved_at, and last_occurred_at for query performance - JSON context field stores metadata (controller/action, job args, etc.) Addresses application error visibility without duplicating existing operational dispatch error tracking in Delivery model.
Simplifies naming to match the /errors route path: - Admin::ErrorRecordsController → Admin::ErrorsController - app/views/admin/error_records/ → app/views/admin/errors/ - Routes now point to admin/errors#action - Layout checks controller_name == 'errors' The model remains Admin::ErrorRecord (singular) as it represents individual error records in the database.
Major changes: - **Rails 8 Integration**: Replace manual rescue_from/around_perform with Rails.error.subscribe() using Admin::Errors::Subscriber - **Model Namespace**: Move ErrorRecord out of Admin namespace to match other models (Webhook, Target, etc.) - **Comprehensive Tests**: Add 73 specs covering models, services, jobs, and controllers with 94.3% line coverage - **Documentation**: Add YARD docs to all public methods and classes - **Bug Fixes**: Fix fingerprint normalization order (UUIDs before numbers) ## Rails 8 Error Subscriber Benefits - Automatic capture from ALL Rails executions (controllers, jobs, console) - Centralized error handling in one subscriber - No need to manually instrument each error source - Survives through Rails upgrades ## Test Coverage - ErrorRecord model: validations, scopes, methods - Admin::Errors::Capture: deduplication, sanitization, fingerprinting - Admin::Errors::Subscriber: Rails error reporting integration - Admin::ErrorCaptureJob: async processing - Admin::ErrorsController: CRUD + resolution workflow - Request specs: authentication, tab filtering, bulk operations ## Code Quality - All tests pass (256 examples, 0 failures) - Rubocop clean (81 files, 0 offenses) - YARD-lint compliant - 94.3% line coverage, 86.11% branch coverage
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.
Overview
Implements a comprehensive error tracking system for hookshot that captures application errors (not operational dispatch failures), with deduplication, aggregation, and an admin UI with resolution workflow.
Key Principle: This tracker focuses on unexpected application failures in controllers, non-dispatch jobs, and services. Dispatch errors remain operational cases handled by existing Delivery model logic.
Features
Core Components
Error Capture Service (
Admin::Errors::Capture)Background Job (
Admin::ErrorCaptureJob)discard_onto prevent infinite retry loopsDatabase Model (
Admin::ErrorRecord)Admin UI (Available at
/errors)Application Integration
rescue_fromin ApplicationController (production only)around_performin ApplicationJob (excludes DispatchJob)Maintenance
rake errors:cleanupdeletes resolved errors older than 30 days0 2 * * * cd /app && bundle exec rake errors:cleanupImplementation Details
Fingerprint Normalization
NUUID0xHEX/tmp/PATHSafety Measures
Database Migration
Creates
error_recordstable with:Testing
Verified functionality:
Routes
GET /errors- List errors with tab filteringGET /errors/:id- Error detail viewPOST /errors/:id/resolve- Mark as resolvedPOST /errors/:id/unresolve- Mark as unresolvedDELETE /errors/:id- Delete single errorDELETE /errors/destroy_all- Bulk delete resolved errorsFuture Enhancements