Sha256: 0c100be6e9c0913c9f15b3ff223567c30af67a8dbdd3907184e3b1717005142c
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true module PlainApm module Hooks class ActionView < ActiveSupportSubscriber NOTIFICATION_PATTERN = /\A[^!]\w+\.action_view\Z/.freeze private def notification_pattern NOTIFICATION_PATTERN end def payload(event) name, base = common_attributes(event) payload = event.payload case name when "render_collection" base.merge({ "identifier" => identifier(payload[:identifier]), "layout" => payload[:layout], "count" => payload[:count], "cache_hits" => payload[:cache_hits] }) when "render_layout" base.merge({ "identifier" => identifier(payload[:identifier]) }) when "render_template" base.merge({ "identifier" => identifier(payload[:identifier]), "layout" => payload[:layout] }) when "render_partial" base.merge({ "identifier" => identifier(payload[:identifier]), "layout" => payload[:layout], "cache_hit" => payload[:cache_hit] }) end end # strip rails root def identifier(id) return id unless defined?(Rails) && Rails.root root = Rails.root.to_s id.start_with?(root) ? id[root.size + 1..-1] : id # standard:disable Style/SlicingWithRange end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
plain_apm-0.6.7 | lib/plain_apm/hooks/action_view.rb |