Sha256: 27fecab815eb84aa347f63e63d158566499cf94ed82a6d14ee0d3ef5f4e5a001

Contents?: true

Size: 1.45 KB

Versions: 16

Compression:

Stored size: 1.45 KB

Contents

require 'ddtrace/contrib/patcher'
require 'ddtrace/ext/app_types'
require 'ddtrace/contrib/aws/ext'

module Datadog
  module Contrib
    module Aws
      # Patcher enables patching of 'aws' module.
      module Patcher
        include Contrib::Patcher

        module_function

        def target_version
          Integration.version
        end

        def patch
          require 'ddtrace/contrib/aws/parsed_context'
          require 'ddtrace/contrib/aws/instrumentation'
          require 'ddtrace/contrib/aws/services'

          add_plugin(Seahorse::Client::Base, *loaded_constants)
        end

        def add_plugin(*targets)
          targets.each { |klass| klass.add_plugin(Instrumentation) }
        end

        def loaded_constants
          # Cross-check services against loaded AWS constants
          # Module#const_get can return a constant from ancestors when there's a miss.
          # If this conincidentally matches another constant, it will attempt to patch
          # the wrong constant, resulting in patch failure.
          available_services = ::Aws.constants & SERVICES.map(&:to_sym)

          available_services.each_with_object([]) do |service, constants|
            next if ::Aws.autoload?(service)
            constants << ::Aws.const_get(service, false).const_get(:Client, false) rescue next
          end
        end

        def get_option(option)
          Datadog.configuration[:aws].get_option(option)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
ddtrace-0.42.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.41.0 lib/ddtrace/contrib/aws/patcher.rb
ls-trace-0.2.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.40.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.39.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.38.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.37.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.36.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.35.2 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.35.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.35.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.34.2 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.34.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.34.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.33.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.33.0 lib/ddtrace/contrib/aws/patcher.rb