Sha256: 65c99ac47a3a7ab87f7ddd78b495c9b6d17d703b3b89fb06722a42d0917fa2de
Contents?: true
Size: 1.44 KB
Versions: 12
Compression:
Stored size: 1.44 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 = attributes_from_notification(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.respond_to?(: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
12 entries across 12 versions & 1 rubygems