class ElasticAPM::Railtie

@api private

Private Instance Methods

attach_subscriber(agent) click to toggle source
# File lib/elastic_apm/railtie.rb, line 60
def attach_subscriber(agent)
  return unless agent

  agent.instrumenter.subscriber = ElasticAPM::Subscriber.new(agent)
end
should_skip?(_config) click to toggle source

rubocop:enable Metrics/MethodLength, Metrics/AbcSize

# File lib/elastic_apm/railtie.rb, line 52
def should_skip?(_config)
  if Rails.const_defined? 'Rails::Console'
    return 'Rails console'
  end

  nil
end
start(config) click to toggle source

rubocop:disable Metrics/MethodLength, Metrics/AbcSize

# File lib/elastic_apm/railtie.rb, line 34
def start(config)
  if (reason = should_skip?(config))
    unless config.disable_start_message?
      config.alert_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")
end