Sha256: 736c5326545d79a86685da906ab5d8d47c41ed797bcfc3384d8785733886e846

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 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
        if File.writable?('log')
          output = Rails.root.join('log/appsignal.log')
        else
          output = STDOUT
        end
        Appsignal.logger = Logger.new(output).tap do |l|
          l.level = Logger::INFO
        end
        Appsignal.flush_in_memory_log
      end

      if Appsignal.active?
        Appsignal.logger.info("Activating appsignal-#{Appsignal::VERSION}")
        at_exit { Appsignal.agent.shutdown(true) }
        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

4 entries across 4 versions & 1 rubygems

Version Path
appsignal-0.6.7 lib/appsignal/railtie.rb
appsignal-0.6.6 lib/appsignal/railtie.rb
appsignal-0.6.5 lib/appsignal/railtie.rb
appsignal-0.6.4 lib/appsignal/railtie.rb