1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Instrument cache store name

This commit is contained in:
Kir Shatrov 2020-10-21 22:44:14 +01:00
parent 7cc2b57b8d
commit 6fa747f294
2 changed files with 5 additions and 1 deletions

View file

@ -715,7 +715,7 @@ module ActiveSupport
logger.debug "Cache #{operation}: #{normalize_key(key, options)}#{options.blank? ? "" : " (#{options.inspect})"}"
end
payload = { key: key }
payload = { key: key, store: self.class.name }
payload.merge!(options) if options.is_a?(Hash)
ActiveSupport::Notifications.instrument("cache_#{operation}.active_support", payload) { yield(payload) }
end

View file

@ -32,6 +32,7 @@ module CacheInstrumentationBehavior
assert_equal :fetch_multi, events[0].payload[:super_operation]
assert_equal ["a", "b"], events[0].payload[:key]
assert_equal ["b"], events[0].payload[:hits]
assert_equal @cache.class.name, events[0].payload[:store]
end
def test_instrumentation_empty_fetch_multi
@ -43,6 +44,7 @@ module CacheInstrumentationBehavior
assert_equal :fetch_multi, events[0].payload[:super_operation]
assert_equal [], events[0].payload[:key]
assert_equal [], events[0].payload[:hits]
assert_equal @cache.class.name, events[0].payload[:store]
end
def test_read_multi_instrumentation
@ -55,6 +57,7 @@ module CacheInstrumentationBehavior
assert_equal %w[ cache_read_multi.active_support ], events.map(&:name)
assert_equal ["a", "b"], events[0].payload[:key]
assert_equal ["b"], events[0].payload[:hits]
assert_equal @cache.class.name, events[0].payload[:store]
end
def test_empty_read_multi_instrumentation
@ -65,6 +68,7 @@ module CacheInstrumentationBehavior
assert_equal %w[ cache_read_multi.active_support ], events.map(&:name)
assert_equal [], events[0].payload[:key]
assert_equal [], events[0].payload[:hits]
assert_equal @cache.class.name, events[0].payload[:store]
end
private