Sha256: 18981b75a65c69edda243b94afd052326e1fc53a766b68a62def599b1b922e96

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

if defined?(::Rails)
  Appsignal.logger.info("Loading Rails (#{Rails.version}) integration")

  require 'appsignal/rack/rails_instrumentation'

  module Appsignal
    module Integrations
      class Railtie < ::Rails::Railtie
        initializer 'appsignal.configure_rails_initialization' do |app|
          Appsignal::Integrations::Railtie.initialize_appsignal(app)
        end

        def self.initialize_appsignal(app)
          # Load config
          Appsignal.config = Appsignal::Config.new(
            Rails.root,
            ENV.fetch('APPSIGNAL_APP_ENV', Rails.env),
            :name => Rails.application.class.parent_name,
            :log_file_path => Rails.root.join('log/appsignal.log')
          )

          # Start logger
          Appsignal.start_logger

          app.middleware.insert_before(
            ActionDispatch::RemoteIp,
            Appsignal::Rack::RailsInstrumentation
          )

          if Appsignal.config.active? &&
            Appsignal.config[:enable_frontend_error_catching] == true
            app.middleware.insert_before(
              Appsignal::Rack::RailsInstrumentation,
              Appsignal::Rack::JSExceptionCatcher,
            )
          end

          Appsignal.start
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appsignal-0.12.rc.7 lib/appsignal/integrations/rails.rb
appsignal-0.12.rc.6 lib/appsignal/integrations/rails.rb
appsignal-0.12.rc.5 lib/appsignal/integrations/rails.rb
appsignal-0.12.beta.54 lib/appsignal/integrations/rails.rb