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



26
27
28
# File 'lib/ddtrace/contrib/aws/patcher.rb', line 26

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

.get_option(option) ⇒ Object



43
44
45
# File 'lib/ddtrace/contrib/aws/patcher.rb', line 43

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

.loaded_constantsObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ddtrace/contrib/aws/patcher.rb', line 30

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
# 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)
end

.target_versionObject



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

def target_version
  Integration.version
end