@@ -15,14 +15,14 @@ module Supervisor
1515 # by tracking the parent process ID (ppid), which is more efficient than tracking
1616 # individual processes.
1717 class ProcessMonitor
18- # Create a new process monitor.
19- #
20- # @parameter interval [Integer] The interval in seconds at which to log process metrics.
21- # @parameter ppid [Integer] The parent process ID to monitor. If nil, uses the current process to capture its children.
22- def initialize ( interval : 60 , ppid : nil )
23- @interval = interval
24- @ppid = ppid || Process . ppid
25- end
18+ # Create a new process monitor.
19+ #
20+ # @parameter interval [Integer] The interval in seconds at which to log process metrics.
21+ # @parameter ppid [Integer] The parent process ID to monitor. If nil, uses the current process to capture its children.
22+ def initialize ( interval : 60 , ppid : nil )
23+ @interval = interval
24+ @ppid = ppid || Process . ppid
25+ end
2626
2727 # @attribute [Integer] The parent process ID being monitored.
2828 attr :ppid
@@ -68,21 +68,21 @@ def status(call)
6868 # Periodically captures and logs process metrics for the entire process tree.
6969 #
7070 # @returns [Async::Task] The task that is running the process monitor.
71- def run
72- Async do
73- while true
74- metrics = self . metrics
75-
76- # Log each process individually for better searchability in log platforms:
77- metrics . each do |process_id , general |
78- Console . info ( self , "Process metrics captured." , general : general )
71+ def run
72+ Async do
73+ while true
74+ metrics = self . metrics
75+
76+ # Log each process individually for better searchability in log platforms:
77+ metrics . each do |process_id , general |
78+ Console . info ( self , "Process metrics captured." , general : general )
79+ end
80+
81+ sleep ( @interval )
7982 end
80-
81- sleep ( @interval )
8283 end
8384 end
8485 end
85- end
8686 end
8787 end
8888end
0 commit comments