Sha256: b14b9c7ce4e2a4141724ac7bbdd8f134b034734746bd922f20bc284e4c8fd7d1

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

module Datadog
  module Contrib
    module Rails
      # Patcher
      module Patcher
        include Base
        register_as :rails, auto_patch: true

        option :service_name
        option :controller_service
        option :cache_service
        option :database_service
        option :distributed_tracing, default: false
        option :template_base_path, default: 'views/'
        option :exception_controller, default: nil
        option :tracer, default: Datadog.tracer

        @patched = false

        class << self
          def patch
            return @patched if patched? || !compatible?
            require_relative 'framework'
            @patched = true
          rescue => e
            Datadog::Tracer.log.error("Unable to apply Rails integration: #{e}")
            @patched
          end

          def patched?
            @patched
          end

          def compatible?
            return if ENV['DISABLE_DATADOG_RAILS']

            defined?(::Rails::VERSION) && ::Rails::VERSION::MAJOR.to_i >= 3
          end

          def active_record_instantiation_tracing_supported?
            Gem.loaded_specs['activerecord'] \
              && Gem.loaded_specs['activerecord'].version >= Gem::Version.new('4.2')
          end
        end
      end
    end
  end
end

require 'ddtrace/contrib/rails/railtie' if Datadog.registry[:rails].compatible?

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddtrace-0.12.0.beta2 lib/ddtrace/contrib/rails/patcher.rb
ddtrace-0.12.0.beta1 lib/ddtrace/contrib/rails/patcher.rb