Method: TingYun::Frameworks::Rails#init_config

Defined in:
lib/ting_yun/frameworks/rails.rb

#init_config(options = {}) ⇒ Object

In versions of Rails prior to 2.0, the rails config was only available to the init.rb, so it had to be passed on from there. This is a best effort to find a config and use that.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ting_yun/frameworks/rails.rb', line 34

def init_config(options = {})
  @config = options[:config]
  # Install the dependency detection,
  if rails_config && ::Rails.configuration.respond_to?(:after_initialize)
    rails_config.after_initialize do
      # This will insure we load all the instrumentation as late as possible.  If the agent
      # is not enabled, it will load a limited amount of instrumentation.
      TingYun::Support::LibraryDetection.detect!
    end
  end

  if !Agent.config[:'nbs.agent_enabled']
    # Might not be running if it does not think mongrel, thin, passenger, etc
    # is running, if it thinks it's a rake task, or if the nbs.agent_enabled is false.
    ::TingYun::Agent.logger.info("TingYun Agent is unable to run.")
  else
    install_browser_monitoring(rails_config)
  end
rescue => e
  ::TingYun::Agent.logger.error("Failure during init_config for Rails. Is Rails required in a non-Rails app? Set TING_YUN_FRAMEWORK=ruby to avoid this message.",
                                 "The Ruby agent will continue running, but Rails-specific features may be missing.",
                                 e)
end