Skip to content

Commit

Permalink
Do provide marking_time and sweeping_time on Ruby version bellow 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
benoittgt committed Jan 10, 2024
1 parent 594c218 commit bbb0d65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ end
| Counter | `major_gc_ops_total` | Major GC operations by process |
| Counter | `minor_gc_ops_total` | Minor GC operations by process |
| Counter | `allocated_objects_total` | Total number of allocated objects by process |
| Gauge | `marking_time` | Marking time spent |
| Gauge | `sweeping_time` | Sweeping time spent |
| Gauge | `marking_time` | Marking time spent (Ruby 3.3 minimum) |
| Gauge | `sweeping_time` | Sweeping time spent (Ruby 3.3 minimum) |

_Metrics marked with * are only collected when `MiniRacer` is defined._

Expand Down
8 changes: 6 additions & 2 deletions lib/prometheus_exporter/instrumentation/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,19 @@ def collect_process_stats(metric)

end

SWEEPING_AND_MARKING = RUBY_VERSION >= "3.3.0"

def collect_gc_stats(metric)
stat = GC.stat
metric[:heap_live_slots] = stat[:heap_live_slots]
metric[:heap_free_slots] = stat[:heap_free_slots]
metric[:major_gc_ops_total] = stat[:major_gc_count]
metric[:minor_gc_ops_total] = stat[:minor_gc_count]
metric[:allocated_objects_total] = stat[:total_allocated_objects]
metric[:marking_time] = stat[:marking_time]
metric[:sweeping_time] = stat[:sweeping_time]
if SWEEPING_AND_MARKING
metric[:marking_time] = stat[:marking_time]
metric[:sweeping_time] = stat[:sweeping_time]
end
end

def collect_v8_stats(metric)
Expand Down

0 comments on commit bbb0d65

Please sign in to comment.