Sha256: b01f85c3b6aa4b97a0f58631814c59ea651e1ed3f479793f84e2d0e80dda6933

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module RooOnRails
  module Railties
    class NewRelic < Rails::Railtie
      initializer 'roo_on_rails.new_relic' do
        Rails.logger.with initializer: 'roo_on_rails.new_relic' do |log|
          log.debug 'loading'
          license_key = ENV['NEW_RELIC_LICENSE_KEY']

          if %w(test development).exclude?(Rails.env.to_s) && (license_key == 'override-me')
            abort 'Aborting: NEW_RELIC_LICENSE_KEY must be set in production environments'
          end

          abort 'Aborting: NEW_RELIC_LICENSE_KEY is required' if license_key.nil?

          path = %w(newrelic.yml config/newrelic.yml).map do |p|
            Pathname.new(p)
          end.find(&:exist?)
          if path
            abort "Aborting: newrelic.yml detected in '#{path.parent.realpath}', should not exist"
          end

          sync_startup = (ENV.fetch('NEW_RELIC_SYNC_STARTUP', 'YES') =~ /\A(YES|TRUE|ON|1)\Z/i)

          require 'newrelic_rpm'
          unless Rails.env.test?
            ::NewRelic::Control.instance.init_plugin(sync_startup: sync_startup)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
roo_on_rails-1.21.0 lib/roo_on_rails/railties/new_relic.rb
roo_on_rails-1.20.0 lib/roo_on_rails/railties/new_relic.rb
roo_on_rails-1.19.0 lib/roo_on_rails/railties/new_relic.rb