Sha256: 142decd3ff5e5b66ae516fdb14c68b8fd2628f7523930756a1dd61d169365c58

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 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

8 entries across 8 versions & 1 rubygems

Version Path
appsignal-0.6.3.beta.2 lib/appsignal/railtie.rb
appsignal-0.6.3.beta.1 lib/appsignal/railtie.rb
appsignal-0.6.2 lib/appsignal/railtie.rb
appsignal-0.6.1 lib/appsignal/railtie.rb
appsignal-0.6.0.beta.2 lib/appsignal/railtie.rb
appsignal-0.6.0.beta.1 lib/appsignal/railtie.rb
appsignal-0.5.5 lib/appsignal/railtie.rb
appsignal-0.5.3 lib/appsignal/railtie.rb