Sha256: 10ac3bd0e02d056347bb2b130b2789d643cc5ee345d1a9a7d871c6097d60102f

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

cs__scoped_require 'contrast/utils/job_servers_running'

module Contrast
  module Agent
    # A Railtie to allow for the automatic hooking of the Agent into a Rails
    # application.
    class Railtie < Rails::Railtie
      include Contrast::Components::Interface
      access_component :agent, :app_context, :logging

      initializer 'Contrast Ruby Agent Initializer' do |app|
        Rails.logger.debug("In railtie ::#{ app.middleware.inspect }") if defined?(Rails) && defined?(Rails.logger)

        if APP_CONTEXT.instrument_middleware_stack?
          AGENT.insert_middleware(app)
        else
          Rails.logger.debug('Detected a running job server, skipping Contrast middleware insertion.')
          logger.debug('Disabling Contrast for process', p_id: Process.pid)
        end
      end

      rake_tasks do
        load 'contrast/tasks/service.rb'
        load 'contrast/tasks/config.rb'
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
contrast-agent-3.13.2 lib/contrast/agent/railtie.rb
contrast-agent-3.13.1 lib/contrast/agent/railtie.rb
contrast-agent-3.13.0 lib/contrast/agent/railtie.rb
contrast-agent-3.12.2 lib/contrast/agent/railtie.rb
contrast-agent-3.12.1 lib/contrast/agent/railtie.rb
contrast-agent-3.12.0 lib/contrast/agent/railtie.rb