Class: TingYun::Frameworks::Rails
- Defined in:
- lib/ting_yun/frameworks/rails.rb
Overview
noinspection ALL
Direct Known Subclasses
Instance Attribute Summary
Attributes included from InstanceMethods
Instance Method Summary collapse
- #env ⇒ Object
-
#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.
- #install_browser_monitoring(config) ⇒ Object
- #rails_config ⇒ Object
-
#rails_root ⇒ Object
noinspection Rails3Deprecated,Rails3Deprecated.
- #root ⇒ Object
Methods included from ClassMethods
#instance, #load_framework_class, #load_test_framework, #local_env, #reset
Methods included from InstanceMethods
#[], #configure_agent, #determine_env, #dispatcher, #framework, #init_plugin, #start_agent
Methods included from Instrumentation
#add_instrumentation, #detect_dependencies, #install_instrumentation, #load_instrumentation_files
Instance Method Details
#env ⇒ Object
10 11 12 |
# File 'lib/ting_yun/frameworks/rails.rb', line 10 def env @evn ||= RAILS_ENV.dup end |
#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( = {}) @config = [: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 |
#install_browser_monitoring(config) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ting_yun/frameworks/rails.rb', line 58 def install_browser_monitoring(config) return if @browser_monitoring_installed @browser_monitoring_installed = true return if config.nil? || !config.respond_to?(:middleware) begin require 'ting_yun/middleware/browser_monitoring' config.middleware.use TingYun::BrowserMonitoring ::TingYun::Agent.logger.debug("Installed TingYun Browser Monitoring middleware") rescue => e ::TingYun::Agent.logger.error("Error installing TingYun Browser Monitoring middleware", e) end end |
#rails_config ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/ting_yun/frameworks/rails.rb', line 23 def rails_config if defined?(::Rails) && ::Rails.respond_to?(:configuration) ::Rails.configuration else @config end end |
#rails_root ⇒ Object
noinspection Rails3Deprecated,Rails3Deprecated
19 20 21 |
# File 'lib/ting_yun/frameworks/rails.rb', line 19 def rails_root RAILS_ROOT if defined?(RAILS_ROOT) end |