Class: Appsignal::Integrations::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/appsignal/integrations/railtie.rb

Class Method Summary collapse

Class Method Details

.initialize_appsignal(app) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/appsignal/integrations/railtie.rb', line 12

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_path => Rails.root.join('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