Sha256: f11c5adf32bf1fa5c7e479a13fb3a1806ec0818ec484c116a49f09a1965f6dc7

Contents?: true

Size: 999 Bytes

Versions: 4

Compression:

Stored size: 999 Bytes

Contents

require 'rails'

module Lens
  class Railtie < Rails::Railtie
    ActiveSupport::Notifications.subscribe('start_processing.action_controller') do |name, started, finished, id, data|
      Trace.create(id)
    end

    ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
      next unless Trace.current
      event = ActiveSupport::Notifications::Event.new(*args)
      Trace.current.add(event) if event.name != 'SCHEMA'
    end

    ActiveSupport::Notifications.subscribe(/^render_(template|action|collection)\.action_view/) do |*args|
      next unless Trace.current
      event = ActiveSupport::Notifications::Event.new(*args)
      Trace.current.add(event)
    end

    ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
      next unless Trace.current
      event = ActiveSupport::Notifications::Event.new(*args)
      if event.payload[:controller] && event.payload[:action]
        Trace.current.complete(event)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lens-0.0.6 lib/lens/railtie.rb
lens-0.0.5 lib/lens/railtie.rb
lens-0.0.4 lib/lens/railtie.rb
lens-0.0.3 lib/lens/railtie.rb