Sha256: 2e737458085e019f9716ab360db1d4eba5be8c97fb47fa350106635932e6513a
Contents?: true
Size: 1.66 KB
Versions: 4
Compression:
Stored size: 1.66 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, source = *event.name.split(".") payload = event.payload base = { "source" => source, "name" => name, "backtrace" => filtered_backtrace, "started_at" => event.time, "finished_at" => event.end, "allocations" => event.allocations } 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
4 entries across 4 versions & 1 rubygems