Skip to content

Commit

Permalink
Merge pull request #1088 from newrelic/ruby32_cache_invalidation_support
Browse files Browse the repository at this point in the history
Support Ruby 3.2+ cache invalidation stats
  • Loading branch information
fallwith authored Apr 16, 2022
2 parents 1f9aab0 + 887319b commit 1a14621
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/new_relic/agent/vm/mri_vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,19 @@ def gather_ruby_vm_stats(snap)
end

if supports?(:constant_cache_invalidations)
snap.constant_cache_invalidations = RubyVM.stat[:global_constant_state]
snap.constant_cache_invalidations = gather_constant_cache_invalidations
end
end

def gather_constant_cache_invalidations
# Ruby >= 3.2 uses :constant_cache
# see: https://github.com/ruby/ruby/pull/5433 and https://bugs.ruby-lang.org/issues/18589
# TODO: now that 3.2+ provides more granual cache invalidation data, should we report it instead of summing?
if RUBY_VERSION >= '3.2.0'
RubyVM.stat[:constant_cache].values.sum
# Ruby < 3.2 uses :global_constant_state
else
RubyVM.stat[:global_constant_state]
end
end

Expand Down

0 comments on commit 1a14621

Please sign in to comment.