Sha256: 5824c105e5fdb386a388a8faa02671f16feea87cb53bacb2e27bd8623145cf02

Contents?: true

Size: 704 Bytes

Versions: 2

Compression:

Stored size: 704 Bytes

Contents

# frozen_string_literal: true

module ElasticAPM
  # @api private
  class Railtie < ::Rails::Railtie
    config.elastic_apm = ActiveSupport::OrderedOptions.new

    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|
        # 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

      if Rails.start(config)
        app.middleware.insert 0, Middleware
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
elastic-apm-3.3.0 lib/elastic_apm/railtie.rb
elastic-apm-3.2.0 lib/elastic_apm/railtie.rb