lib/elastic_apm/railtie.rb in elastic-apm-2.9.1 vs lib/elastic_apm/railtie.rb in elastic-apm-2.10.0
- old
+ new
@@ -5,14 +5,19 @@
module ElasticAPM
# @api private
class Railtie < Rails::Railtie
config.elastic_apm = ActiveSupport::OrderedOptions.new
- Config::DEFAULTS.each { |option, value| config.elastic_apm[option] = value }
+ Config.schema.each do |key, args|
+ next unless args.length > 1
+ config.elastic_apm[key] = args.last[:default]
+ end
initializer 'elastic_apm.initialize' do |app|
- config = Config.new(app.config.elastic_apm.merge(app: app)).tap do |c|
+ config = Config.new(app.config.elastic_apm).tap do |c|
+ c.app = app
+
# Prepend Rails.root to log_path if present
if c.log_path && !c.log_path.start_with?('/')
c.log_path = Rails.root.join(c.log_path)
end
end
@@ -33,21 +38,21 @@
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def start(config)
if (reason = should_skip?(config))
unless config.disable_start_message?
- config.alert_logger.info "Skipping because: #{reason}. " \
+ config.logger.info "Skipping because: #{reason}. " \
"Start manually with `ElasticAPM.start'"
end
return
end
ElasticAPM.start(config).tap do |agent|
attach_subscriber(agent)
end
rescue StandardError => e
- config.alert_logger.error format('Failed to start: %s', e.message)
- config.alert_logger.debug "Backtrace:\n" + e.backtrace.join("\n")
+ config.logger.error format('Failed to start: %s', e.message)
+ config.logger.debug "Backtrace:\n" + e.backtrace.join("\n")
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
def should_skip?(_config)
if Rails.const_defined? 'Rails::Console'