Sha256: 433d9998f8986187c85b942e11d3049dd8c9e4ead9fcc25de2a758a9c4a94a15

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module AppMap
  # Railtie connects the AppMap recorder to Rails-specific features.
  class Railtie < ::Rails::Railtie
    initializer 'appmap.remote_recording' do
      require 'appmap/middleware/remote_recording'
      Rails.application.config.middleware.insert_before \
        ActionDispatch::Executor,
        AppMap::Middleware::RemoteRecording
    end

    # appmap.subscribe subscribes to ActiveSupport Notifications so that they can be recorded as
    # AppMap events.
    initializer 'appmap.subscribe' do |_| # params: app
      require 'appmap/handler/rails/sql_handler'
      require 'appmap/handler/rails/request_handler'
      ActiveSupport::Notifications.subscribe 'sql.sequel', AppMap::Handler::Rails::SQLHandler.new
      ActiveSupport::Notifications.subscribe 'sql.active_record', AppMap::Handler::Rails::SQLHandler.new

      http_hook_available = ActionController::Instrumentation.public_instance_methods.include?(:process_action)
      if http_hook_available
        AppMap::Handler::Rails::RequestHandler::HookMethod.new.activate
      else
        ActiveSupport::Notifications.subscribe(
          'start_processing.action_controller',
          AppMap::Handler::Rails::RequestHandler::RequestListener.method(:begin_request)
        )
      end
    end
  end
end if ENV['APPMAP'] == 'true'

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
appmap-0.91.0 lib/appmap/railtie.rb
appmap-0.90.1 lib/appmap/railtie.rb
appmap-0.90.0 lib/appmap/railtie.rb
appmap-0.89.0 lib/appmap/railtie.rb
appmap-0.88.0 lib/appmap/railtie.rb