Module: Henitai::Integration::SchedulerDiagnostics
- Defined in:
- lib/henitai/integration/rspec_process_runner.rb
Overview
Tracks real OS child pids for scheduler observability. Gated on HENITAI_DEBUG_SCHEDULER=1. Thread-safe.
Class Method Summary collapse
- .child_ended(pid) ⇒ Object
- .child_started(pid) ⇒ Object
- .enabled? ⇒ Boolean
- .reset! ⇒ Object
- .summary ⇒ Object
Class Method Details
.child_ended(pid) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/henitai/integration/rspec_process_runner.rb', line 29 def child_ended(pid) return if pid.nil? || !enabled? ended_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) @mutex.synchronize do @live_count -= 1 entry = @intervals.rfind { |i| i[:pid] == pid && i[:ended_at].nil? } entry[:ended_at] = ended_at if entry end end |
.child_started(pid) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/henitai/integration/rspec_process_runner.rb', line 18 def child_started(pid) return unless enabled? started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) @mutex.synchronize do @live_count += 1 @max_concurrent = [@max_concurrent, @live_count].max @intervals << { pid: pid, started_at: started_at, ended_at: nil } end end |
.enabled? ⇒ Boolean
14 15 16 |
# File 'lib/henitai/integration/rspec_process_runner.rb', line 14 def enabled? ENV["HENITAI_DEBUG_SCHEDULER"] == "1" end |
.reset! ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/henitai/integration/rspec_process_runner.rb', line 44 def reset! @mutex.synchronize do @intervals = [] @live_count = 0 @max_concurrent = 0 end end |
.summary ⇒ Object
40 41 42 |
# File 'lib/henitai/integration/rspec_process_runner.rb', line 40 def summary @mutex.synchronize { { max_concurrent: @max_concurrent, intervals: @intervals.dup } } end |