Class: RailsErrorDashboard::Services::SystemHealthSnapshot
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Services::SystemHealthSnapshot
- Defined in:
- lib/rails_error_dashboard/services/system_health_snapshot.rb
Overview
Pure algorithm: Capture runtime health metrics at error time
Captures GC stats, process RSS memory, thread count, connection pool stats, and Puma stats. NOT memoized — fresh data every call (unlike EnvironmentSnapshot). Every metric call individually wrapped in rescue => nil.
Safety contract (from HOST_APP_SAFETY.md):
-
Total snapshot < 1ms budget
-
NEVER ObjectSpace.each_object or ObjectSpace.count_objects (heap scan)
-
NEVER Thread.list.map(&:backtrace) (GVL hold)
-
Thread.list.count only (O(1), safe)
-
Process memory: Linux procfs ONLY, no fork/subprocess ever
-
No new gems, no global state, no Thread.current, no mutex
Class Method Summary collapse
-
.capture ⇒ Hash
Capture current system health metrics.
Instance Method Summary collapse
-
#capture ⇒ Hash
Health snapshot.
Class Method Details
.capture ⇒ Hash
Capture current system health metrics
21 22 23 24 25 26 |
# File 'lib/rails_error_dashboard/services/system_health_snapshot.rb', line 21 def self.capture new.capture rescue => e RailsErrorDashboard::Logger.debug("[RailsErrorDashboard] SystemHealthSnapshot.capture failed: #{e.}") { captured_at: Time.current.iso8601 } end |
Instance Method Details
#capture ⇒ Hash
Returns Health snapshot.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rails_error_dashboard/services/system_health_snapshot.rb', line 29 def capture { gc: gc_stats, process_memory_mb: process_memory_mb, thread_count: thread_count, connection_pool: connection_pool_stats, puma: puma_stats, job_queue: job_queue_stats, captured_at: Time.current.iso8601 } end |