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



32
33
34
# File 'lib/ddtrace/contrib/aws/patcher.rb', line 32

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



36
37
38
39
40
41
# File 'lib/ddtrace/contrib/aws/patcher.rb', line 36

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

.patchObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ddtrace/contrib/aws/patcher.rb', line 18

def patch
  do_once(:aws) do
    begin
      require 'ddtrace/contrib/aws/parsed_context'
      require 'ddtrace/contrib/aws/instrumentation'
      require 'ddtrace/contrib/aws/services'

      add_plugin(Seahorse::Client::Base, *loaded_constants)
    rescue StandardError => e
      Datadog::Tracer.log.error("Unable to apply AWS integration: #{e}")
    end
  end
end

.patched?Boolean

Returns:

  • (Boolean)


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

def patched?
  done?(:aws)
end