Sha256: d1d31e1caeaf21054a6ed62bff3a86d57a2116d36e576e7b3a5e05feafc25430

Contents?: true

Size: 898 Bytes

Versions: 15

Compression:

Stored size: 898 Bytes

Contents

module Timber
  module Events
    # The template render event track template renderings and their performance.
    #
    # @note This event should be installed automatically through probes,
    #   such as the {Probes::ActionViewLogSubscriber} probe.
    class TemplateRender < Timber::Event
      attr_reader :message, :name, :time_ms

      def initialize(attributes)
        @message = attributes[:message] || raise(ArgumentError.new(":message is required"))
        @name = attributes[:name] || raise(ArgumentError.new(":name is required"))
        @time_ms = attributes[:time_ms] || raise(ArgumentError.new(":time_ms is required"))
        @time_ms = @time_ms.round(6)
      end

      def to_hash
        {name: name, time_ms: time_ms}
      end
      alias to_h to_hash

      def as_json(_options = {})
        {:server_side_app => {:template_render => to_hash}}
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
timber-1.1.14 lib/timber/events/template_render.rb
timber-1.1.13 lib/timber/events/template_render.rb
timber-1.1.12 lib/timber/events/template_render.rb
timber-1.1.11 lib/timber/events/template_render.rb
timber-1.1.10 lib/timber/events/template_render.rb
timber-1.1.9 lib/timber/events/template_render.rb
timber-1.1.8 lib/timber/events/template_render.rb
timber-1.1.7 lib/timber/events/template_render.rb
timber-1.1.6 lib/timber/events/template_render.rb
timber-1.1.5 lib/timber/events/template_render.rb
timber-1.1.4 lib/timber/events/template_render.rb
timber-1.1.3 lib/timber/events/template_render.rb
timber-1.1.2 lib/timber/events/template_render.rb
timber-1.1.1 lib/timber/events/template_render.rb
timber-1.1.0 lib/timber/events/template_render.rb