File tree 3 files changed +10
-2
lines changed
3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,9 @@ class Process < Base
22
22
gc_major_by : "Reason the last major GC was triggered" ,
23
23
major_gc_count : "Major GC operations by process" ,
24
24
minor_gc_count : "Minor GC operations by process" ,
25
- total_allocated_objects : "Total number of allocateds objects by process" ,
25
+ total_allocated_objects : "Total number of allocated objects by process" ,
26
26
job_failures : "Number of scheduled and regular jobs that failed in a process" ,
27
+ process_cpu_seconds_total : "Total CPU time used by the process" ,
27
28
}
28
29
29
30
attribute :type ,
@@ -45,7 +46,8 @@ class Process < Base
45
46
:active_record_connections_count ,
46
47
:active_record_failover_count ,
47
48
:redis_failover_count ,
48
- :job_failures
49
+ :job_failures ,
50
+ :process_cpu_seconds_total
49
51
50
52
def initialize
51
53
@active_record_connections_count = { }
Original file line number Diff line number Diff line change @@ -56,6 +56,10 @@ def rss
56
56
end
57
57
end
58
58
59
+ def process_cpu_seconds_total
60
+ ::Process . clock_gettime ( ::Process ::CLOCK_PROCESS_CPUTIME_ID )
61
+ end
62
+
59
63
def collect_scheduler_stats ( metric )
60
64
metric . deferred_jobs_queued = Scheduler ::Defer . length
61
65
@@ -80,6 +84,7 @@ def collect_process_stats(metric)
80
84
metric . pid = pid
81
85
metric . rss = rss
82
86
metric . thread_count = Thread . list . count
87
+ metric . process_cpu_seconds_total = process_cpu_seconds_total
83
88
end
84
89
85
90
def collect_gc_stats ( metric )
Original file line number Diff line number Diff line change 22
22
expect ( metric . v8_physical_size ) . to be > 0
23
23
expect ( metric . pid ) . to be > 0
24
24
expect ( metric . thread_count ) . to be > 0
25
+ expect ( metric . process_cpu_seconds_total ) . to be > 0
25
26
26
27
# macos does not support these metrics
27
28
expect ( metric . rss ) . to be > 0 unless RbConfig ::CONFIG [ "arch" ] =~ /darwin/
You can’t perform that action at this time.
0 commit comments