Module: NSA::Collectors::ActiveSupportCache
- Extended by:
- Statsd::Publisher
- Defined in:
- lib/nsa/collectors/active_support_cache.rb
Constant Summary collapse
- CACHE_TYPES =
{ "cache_delete.active_support" => :delete, "cache_exist?.active_support" => :exist?, "cache_fetch_hit.active_support" => :fetch_hit, "cache_generate.active_support" => :generate, "cache_read.active_support" => :read, "cache_write.active_support" => :write, }.freeze
Class Method Summary collapse
Methods included from Statsd::Publisher
__statsd_publish, statsd_count, statsd_decrement, statsd_gauge, statsd_increment, statsd_set, statsd_time, statsd_timing
Class Method Details
.collect(key_prefix) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nsa/collectors/active_support_cache.rb', line 18 def self.collect(key_prefix) ::ActiveSupport::Notifications.subscribe(/cache_[^.]+.active_support/) do |*event_args| event = ::ActiveSupport::Notifications::Event.new(*event_args) cache_type = CACHE_TYPES.fetch(event.name) do event.name.split(".").first.gsub(/^cache_/, "") end if cache_type == :read cache_type = event.payload[:hit] ? :read_hit : :read_miss end stat_name = "#{key_prefix}.#{cache_type}.duration" statsd_timing(stat_name, event.duration) end end |