Sha256: 425637e9c00bcf7c74c54424c1f29dceb6c758fe04a5c6c258d6ef94567110dc
Contents?: true
Size: 1.15 KB
Versions: 5
Compression:
Stored size: 1.15 KB
Contents
require "timber/event" module Timber module Events # The template render event track template renderings and their performance. # # @note This event should be installed automatically through integrations, # such as the {Integrations::ActionView::LogSubscriber} integration. class TemplateRender < Timber::Event MESSAGE_MAX_BYTES = 8192.freeze NAME_MAX_BYTES = 1024.freeze attr_reader :message, :name, :time_ms def initialize(attributes) normalizer = Util::AttributeNormalizer.new(attributes) @message = normalizer.fetch!(:message, :string, :limit => MESSAGE_MAX_BYTES) @name = normalizer.fetch!(:name, :string, :limit => NAME_MAX_BYTES) @time_ms = normalizer.fetch!(:time_ms, :float, :precision => 6) end def to_hash @to_hash ||= Util::NonNilHashBuilder.build do |h| h.add(:name, name) h.add(:time_ms, time_ms) end end alias to_h to_hash # Builds a hash representation containing simple objects, suitable for serialization (JSON). def as_json(_options = {}) {:template_render => to_hash} end end end end
Version data entries
5 entries across 5 versions & 1 rubygems