Module: Datadog::Contrib::Aws::Patcher

Includes:
Patcher
Defined in:
lib/ddtrace/contrib/aws/patcher.rb

Overview

Patcher enables patching of 'aws' module.

Class Method Summary collapse

Methods included from Patcher

included

Class Method Details

.add_plugin(*targets) ⇒ Object



30
31
32
# File 'lib/ddtrace/contrib/aws/patcher.rb', line 30

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

.get_option(option) ⇒ Object



48
49
50
# File 'lib/ddtrace/contrib/aws/patcher.rb', line 48

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

.loaded_constantsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# 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

.patchObject



18
19
20
21
22
23
24
25
26
27
28
# 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_versionObject



14
15
16
# File 'lib/ddtrace/contrib/aws/patcher.rb', line 14

def target_version
  Integration.version
end