Sha256: 839b3b8a86d31c9c2f71560d4935674a5906c56a054cd5c6b89fbcf7e665d8ae

Contents?: true

Size: 1.93 KB

Versions: 7

Compression:

Stored size: 1.93 KB

Contents

# Control subclass instantiated when Rails is detected.  Contains
# Rails specific configuration, instrumentation, environment values,
# etc.
require 'new_relic/control/frameworks/rails'
module NewRelic
  class Control
    module Frameworks
      class Rails3 < NewRelic::Control::Frameworks::Rails

        def env
          ::Rails.env.to_s
        end
        
        # Rails can return an empty string from this method, causing
        # the agent not to start even when it is properly in a rails 3
        # application, so we test the value to make sure it actually
        # has contents, and bail to the parent class if it is empty.
        def root
          value = ::Rails.root.to_s
          if value.empty?
            super
          else
            value
          end
        end

        def logger
          ::Rails.logger
        end


        def log!(msg, level=:info)
          super unless should_log?
          logger.send(level, msg)
        rescue Exception => e
          super
        end

        def to_stdout(msg)
          logger.info(msg)
        rescue
          super
        end

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

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

        protected

        # Collect the Rails::Info into an associative array as well as the list of plugins
        def append_environment_info
          local_env.append_environment_value('Rails version'){ version }
          local_env.append_environment_value('Rails threadsafe') do
            true == ::Rails.configuration.action_controller.allow_concurrency
          end
          local_env.append_environment_value('Rails Env') { env }
          local_env.append_gem_list do
            bundler_gem_list
          end
          local_env.append_plugin_list { ::Rails.configuration.plugins.to_a }
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
ghazel-newrelic_rpm-3.1.0.1 lib/new_relic/control/frameworks/rails3.rb
newrelic_rpm-3.1.0 lib/new_relic/control/frameworks/rails3.rb
newrelic_rpm-3.1.0.beta5 lib/new_relic/control/frameworks/rails3.rb
newrelic_rpm-3.1.0.beta4 lib/new_relic/control/frameworks/rails3.rb
newrelic_rpm-3.1.0.djlogging2 lib/new_relic/control/frameworks/rails3.rb
newrelic_rpm-3.1.0.djlogging lib/new_relic/control/frameworks/rails3.rb
newrelic_rpm-3.1.0.beta3 lib/new_relic/control/frameworks/rails3.rb