Class: NewRelic::Control::Frameworks::Rails3

Inherits:
Rails show all
Defined in:
lib/new_relic/control/frameworks/rails3.rb

Overview

Control subclass instantiated when Rails is detected. Contains Rails 3.0+ specific configuration, instrumentation, environment values, etc. Many methods are inherited from the NewRelic::Control::Frameworks::Rails class, where the two do not differ

Direct Known Subclasses

Rails4

Instance Attribute Summary

Attributes included from InstanceMethods

#local_env

Instance Method Summary collapse

Methods inherited from Rails

#install_agent_hooks, #install_browser_monitoring, #install_developer_mode, #rails_config, #rails_version, #root

Methods inherited from Ruby

#root

Methods included from ClassMethods

#instance, #load_framework_class, #load_test_framework, #local_env, #new_instance, #newrelic_root, #reset

Methods included from InstanceMethods

#[], #app, #dispatcher, #framework, #init_plugin, #newrelic_root, #settings, #start_agent

Methods included from Instrumentation

#add_instrumentation, #install_instrumentation, #load_instrumentation_files, #load_samplers

Methods included from ServerMethods

#api_server, #convert_to_ip_address, #proxy_server, #resolve_ip_address, #server, #server_from_host

Methods included from Profiling

#profiling=, #profiling?, #profiling_available?

Instance Method Details

#add_error_collector_middlewareObject



35
36
37
38
39
# File 'lib/new_relic/control/frameworks/rails3.rb', line 35

def add_error_collector_middleware
  rails_config.middleware.use NewRelic::Rack::ErrorCollector
rescue => e
  NewRelic::Agent.logger.debug("Error encountered installing ErrorCollector: #{e}")
end

#envObject



17
18
19
# File 'lib/new_relic/control/frameworks/rails3.rb', line 17

def env
  @env ||= ::Rails.env.to_s
end

#init_config(options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/new_relic/control/frameworks/rails3.rb', line 25

def init_config(options={})
  super
  if Agent.config[:agent_enabled] && Agent.config[:'error_collector.enabled']
    if !rails_config.middleware.respond_to?(:include?) ||
        !rails_config.middleware.include?(NewRelic::Rack::ErrorCollector)
      add_error_collector_middleware
    end
  end
end

#rails_rootObject



21
22
23
# File 'lib/new_relic/control/frameworks/rails3.rb', line 21

def rails_root
  ::Rails.root.to_s
end

#vendor_rootObject



41
42
43
# File 'lib/new_relic/control/frameworks/rails3.rb', line 41

def vendor_root
  @vendor_root ||= File.join(root,'vendor','rails')
end

#versionObject



45
46
47
# File 'lib/new_relic/control/frameworks/rails3.rb', line 45

def version
  @rails_version ||= NewRelic::VersionNumber.new(::Rails::VERSION::STRING)
end