module Datadog::Contrib::Aws::Patcher

Patcher enables patching of 'aws' module.

Public Instance Methods

add_plugin(*targets) click to toggle source
# File lib/ddtrace/contrib/aws/patcher.rb, line 30
def add_plugin(*targets)
  targets.each { |klass| klass.add_plugin(Instrumentation) }
end
get_option(option) click to toggle source
# File lib/ddtrace/contrib/aws/patcher.rb, line 48
def get_option(option)
  Datadog.configuration[:aws].get_option(option)
end
loaded_constants() click to toggle source
# File lib/ddtrace/contrib/aws/patcher.rb, line 34
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
patch() click to toggle source
# File lib/ddtrace/contrib/aws/patcher.rb, line 18
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)

  # Special handling for S3 URL Presigning.
  # @see {Datadog::Contrib::Aws::S3Presigner}
  ::Aws::S3::Presigner.prepend(S3Presigner) if defined?(::Aws::S3::Presigner)
end
target_version() click to toggle source
# File lib/ddtrace/contrib/aws/patcher.rb, line 14
def target_version
  Integration.version
end