Sha256: e4d77444994def6d45f1751d015fee2567776190ecab20638c9aed104ffd9cd5

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Appsignal
  class Railtie < Rails::Railtie
    initializer "appsignal.configure_rails_initialization" do |app|
      # Some apps when run from the console do not have Rails.root set, there's
      # currently no way to spec this.
      if Rails.root
        Appsignal.logger = Logger.new(Rails.root.join('log/appsignal.log')).tap do |l|
          l.level = Logger::INFO
        end
        Appsignal.flush_in_memory_log
      end

      if Appsignal.active?
        app.middleware.
          insert_before(ActionDispatch::RemoteIp, Appsignal::Listener)

        Appsignal.subscriber = ActiveSupport::Notifications.subscribe(/^[^!]/) do |*args|
          if Appsignal::Transaction.current
            event = ActiveSupport::Notifications::Event.new(*args)
            if event.name == 'process_action.action_controller'
              Appsignal::Transaction.current.set_process_action_event(event)
            end
            Appsignal::Transaction.current.add_event(event)
          end
        end
      end
    end
  end
end

require 'appsignal/to_appsignal_hash'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appsignal-0.5.1 lib/appsignal/railtie.rb