Skip to content

Commit

Permalink
Merge pull request #2320 from newrelic/_why_and_zed_and_wayne
Browse files Browse the repository at this point in the history
  • Loading branch information
fallwith authored Nov 17, 2023
2 parents 0bbd74d + a78ac44 commit 46a8ca9
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions lib/new_relic/agent/vm/mri_vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def gather_stats(snap)

def gather_gc_stats(snap)
gather_gc_runs(snap) if supports?(:gc_runs)
gather_derived_stats(snap) if GC.respond_to?(:stat)
gather_derived_stats(snap)
end

def gather_gc_runs(snap)
Expand All @@ -33,19 +33,11 @@ def gather_gc_runs(snap)

def gather_derived_stats(snap)
stat = GC.stat
snap.total_allocated_object = derive_from_gc_stats(%i[total_allocated_objects total_allocated_object], stat)
snap.major_gc_count = derive_from_gc_stats(:major_gc_count, stat)
snap.minor_gc_count = derive_from_gc_stats(:minor_gc_count, stat)
snap.heap_live = derive_from_gc_stats(%i[heap_live_slots heap_live_slot heap_live_num], stat)
snap.heap_free = derive_from_gc_stats(%i[heap_free_slots heap_free_slot heap_free_num], stat)
end

def derive_from_gc_stats(keys, stat)
Array(keys).each do |key|
value = stat[key]
return value if value
end
nil
snap.total_allocated_object = stat.fetch(:total_allocated_objects, nil)
snap.major_gc_count = stat.fetch(:major_gc_count, nil)
snap.minor_gc_count = stat.fetch(:minor_gc_count, nil)
snap.heap_live = stat.fetch(:heap_live_slots, nil)
snap.heap_free = stat.fetch(:heap_free_slots, nil)
end

def gather_gc_time(snap)
Expand Down

0 comments on commit 46a8ca9

Please sign in to comment.