Skip to content

Commit e406e51

Browse files
committed
Updated README
1 parent 6dc6c68 commit e406e51

File tree

3 files changed

+279
-166266
lines changed

3 files changed

+279
-166266
lines changed

README.md

Lines changed: 158 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
- [Installation](#installation)
2323
- [Quick Setup](#quick-setup)
2424
- [Basic Configuration](#basic-configuration)
25+
- [Background Job Monitoring](#background-job-monitoring)
26+
- [Overview](#overview)
27+
- [Supported Adapters](#supported-adapters)
28+
- [Job Tracking Configuration](#job-tracking-configuration)
29+
- [Privacy & Security](#privacy--security)
2530
- [Authentication](#authentication)
2631
- [Authentication Setup](#authentication-setup)
2732
- [Authentication Examples](#authentication-examples)
@@ -54,16 +59,24 @@ Rails Pulse is a comprehensive performance monitoring and debugging gem that pro
5459
- Interactive dashboard with response time charts and request analytics
5560
- SQL query performance tracking with slow query identification
5661
- Route-specific metrics with configurable performance thresholds
62+
- **Background job monitoring** with execution tracking and failure analysis
5763
- Week-over-week trend analysis with visual indicators
5864

65+
### Background Job Tracking
66+
- **Universal job tracking** compatible with all ActiveJob adapters
67+
- Monitor job performance, failures, and retries
68+
- Track individual job executions with detailed metrics
69+
- View operations and SQL queries executed during jobs
70+
- Configurable privacy controls for job arguments
71+
5972
### Developer Experience
6073
- Zero configuration setup with sensible defaults
6174
- Beautiful responsive interface with dark/light mode
6275
- Smart caching with minimal performance overhead
6376
- Multiple database support (SQLite, PostgreSQL, MySQL)
6477

6578
### Organization & Filtering
66-
- Flexible tagging system for routes, requests, and queries
79+
- Flexible tagging system for routes, requests, queries, and jobs
6780
- Filter performance data by custom tags
6881
- Organize monitoring data by environment, priority, or custom categories
6982

@@ -172,10 +185,21 @@ RailsPulse.configure do |config|
172185
critical: 1000
173186
}
174187

188+
# Set performance thresholds for background jobs (in milliseconds)
189+
config.job_thresholds = {
190+
slow: 5_000, # 5 seconds
191+
very_slow: 30_000, # 30 seconds
192+
critical: 60_000 # 1 minute
193+
}
194+
175195
# Asset tracking configuration
176196
config.track_assets = false # Ignore asset requests by default
177197
config.custom_asset_patterns = [] # Additional asset patterns to ignore
178198

199+
# Job tracking configuration
200+
config.track_jobs = true # Enable background job tracking
201+
config.capture_job_arguments = false # Disable argument capture for privacy
202+
179203
# Rails Pulse mount path (optional)
180204
# Specify if Rails Pulse is mounted at a custom path to prevent self-tracking
181205
config.mount_path = nil # e.g., "/admin/monitoring"
@@ -184,18 +208,22 @@ RailsPulse.configure do |config|
184208
config.ignored_routes = [] # Array of strings or regex patterns
185209
config.ignored_requests = [] # Array of request patterns to ignore
186210
config.ignored_queries = [] # Array of query patterns to ignore
211+
config.ignored_jobs = [] # Array of job class names to ignore
212+
config.ignored_queues = [] # Array of queue names to ignore
187213

188214
# Tagging system - define available tags for categorizing performance data
189215
config.tags = ["production", "staging", "critical", "needs-optimization"]
190216

191217
# Data cleanup
192-
config.archiving_enabled = true # Enable automatic cleanup
193-
config.full_retention_period = 2.weeks # Delete records older than this
194-
config.max_table_records = { # Maximum records per table
195-
rails_pulse_requests: 10000,
196-
rails_pulse_operations: 50000,
197-
rails_pulse_routes: 1000,
198-
rails_pulse_queries: 500
218+
config.archiving_enabled = true # Enable automatic cleanup
219+
config.full_retention_period = 30.days # Delete records older than this
220+
config.max_table_records = { # Maximum records per table
221+
rails_pulse_operations: 100_000,
222+
rails_pulse_requests: 50_000,
223+
rails_pulse_job_runs: 50_000,
224+
rails_pulse_queries: 10_000,
225+
rails_pulse_routes: 1_000,
226+
rails_pulse_jobs: 1_000
199227
}
200228

201229
# Multiple database support (optional)
@@ -206,6 +234,117 @@ RailsPulse.configure do |config|
206234
end
207235
```
208236

237+
## Background Job Monitoring
238+
239+
Rails Pulse provides comprehensive monitoring for ActiveJob background jobs, tracking performance, failures, and execution details across all major job adapters.
240+
241+
### Overview
242+
243+
Background job monitoring is **enabled by default** and works automatically with any ActiveJob adapter. Rails Pulse captures:
244+
245+
- **Job execution metrics**: Duration, status, retry attempts
246+
- **Failure tracking**: Error class, error message, failure rates
247+
- **Performance analysis**: Slow jobs, aggregate metrics by job class
248+
- **Operation timeline**: SQL queries and operations during job execution
249+
- **Job arguments**: Optional capture for debugging (disabled by default for privacy)
250+
251+
Access the jobs dashboard at `/rails_pulse/jobs` to view:
252+
- All job classes with aggregate metrics (total runs, failure rate, average duration)
253+
- Individual job executions with detailed performance data
254+
- Filtering by time range, status, queue, and performance thresholds
255+
- Tagging support for organizing jobs by team, priority, or category
256+
257+
### Supported Adapters
258+
259+
Rails Pulse works with all ActiveJob adapters through universal tracking:
260+
261+
- **Sidekiq** - Enhanced tracking via custom middleware
262+
- **Solid Queue** - Universal ActiveJob tracking
263+
- **Good Job** - Universal ActiveJob tracking
264+
- **Delayed Job** - Enhanced tracking via custom plugin
265+
- **Resque** - Universal ActiveJob tracking
266+
- **Any ActiveJob adapter** - Falls back to universal tracking
267+
268+
No additional configuration needed - job tracking works out of the box with your existing setup.
269+
270+
### Job Tracking Configuration
271+
272+
Customize job tracking in your Rails Pulse initializer:
273+
274+
```ruby
275+
RailsPulse.configure do |config|
276+
# Enable or disable job tracking (default: true)
277+
config.track_jobs = true
278+
279+
# Set performance thresholds for jobs (in milliseconds)
280+
config.job_thresholds = {
281+
slow: 5_000, # 5 seconds
282+
very_slow: 30_000, # 30 seconds
283+
critical: 60_000 # 1 minute
284+
}
285+
286+
# Ignore specific job classes from tracking
287+
config.ignored_jobs = [
288+
"ActiveStorage::AnalyzeJob",
289+
"ActiveStorage::PurgeJob"
290+
]
291+
292+
# Ignore specific queues from tracking
293+
config.ignored_queues = ["low_priority", "mailers"]
294+
295+
# Capture job arguments for debugging (default: false)
296+
# WARNING: May expose sensitive data - use with caution
297+
config.capture_job_arguments = false
298+
299+
# Configure adapter-specific settings
300+
config.job_adapters = {
301+
sidekiq: { enabled: true, track_queue_depth: false },
302+
solid_queue: { enabled: true, track_recurring: false },
303+
good_job: { enabled: true, track_cron: false },
304+
delayed_job: { enabled: true },
305+
resque: { enabled: true }
306+
}
307+
end
308+
```
309+
310+
**Disabling job tracking for specific jobs:**
311+
312+
```ruby
313+
class MyBackgroundJob < ApplicationJob
314+
# Skip Rails Pulse tracking for this job
315+
def perform(*args)
316+
RailsPulse.with_tracking_disabled do
317+
# Job logic here
318+
end
319+
end
320+
end
321+
```
322+
323+
### Privacy & Security
324+
325+
**Job argument capture is disabled by default** to protect sensitive information. Job arguments may contain:
326+
- User credentials or tokens
327+
- Personal identifiable information (PII)
328+
- API keys or secrets
329+
- Sensitive business data
330+
331+
Only enable `capture_job_arguments` in development or when explicitly needed for debugging. Consider using parameter filtering if you need to capture arguments:
332+
333+
```ruby
334+
# In your job class
335+
class SensitiveJob < ApplicationJob
336+
def perform(user_id:, api_key:)
337+
# Rails Pulse will track execution but not arguments by default
338+
end
339+
end
340+
```
341+
342+
**Performance impact:**
343+
- Minimal overhead: ~1-2ms per job execution
344+
- No blocking of job processing
345+
- Configurable cleanup prevents database growth
346+
- Can be disabled per-job or globally
347+
209348
## Authentication
210349

211350
Rails Pulse supports flexible authentication to secure access to your monitoring dashboard.
@@ -257,7 +396,7 @@ config.authentication_method = proc {
257396

258397
## Tagging System
259398

260-
Rails Pulse includes a flexible tagging system that allows you to categorize and organize your performance data. Tag routes, requests, and queries with custom labels to better organize and filter your monitoring data.
399+
Rails Pulse includes a flexible tagging system that allows you to categorize and organize your performance data. Tag routes, requests, queries, jobs, and job runs with custom labels to better organize and filter your monitoring data.
261400

262401
### Configuring Tags
263402

@@ -280,7 +419,7 @@ end
280419

281420
**Tag from the UI:**
282421

283-
1. Navigate to any route, request, or query detail page
422+
1. Navigate to any route, request, query, job, or job run detail page
284423
2. Click the "+ tag" button next to the record
285424
3. Select from your configured tags
286425
4. Remove tags by clicking the × button on any tag badge
@@ -297,6 +436,15 @@ route.add_tag("high-traffic")
297436
query = RailsPulse::Query.find_by(normalized_sql: "SELECT * FROM users WHERE id = ?")
298437
query.add_tag("needs-optimization")
299438

439+
# Tag a job
440+
job = RailsPulse::Job.find_by(name: "UserNotificationJob")
441+
job.add_tag("high-priority")
442+
job.add_tag("user-facing")
443+
444+
# Tag a specific job run
445+
job_run = RailsPulse::JobRun.find_by(run_id: "abc123")
446+
job_run.add_tag("investigated")
447+
300448
# Remove a tag
301449
route.remove_tag("critical")
302450

0 commit comments

Comments
 (0)