Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Ruby 3.2+ cache invalidation stats #1088

Merged
merged 3 commits into from
Apr 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_invalidatiions
fallwith marked this conversation as resolved.
Show resolved Hide resolved
end
end

def gather_constant_cache_invalidatiions
fallwith marked this conversation as resolved.
Show resolved Hide resolved
# 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