Sha256: 7d17d76a321291931f49bc535598856712eb7f7043cb7d54b558d44aac88184b

Contents?: true

Size: 1.26 KB

Versions: 26

Compression:

Stored size: 1.26 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 patched?
          done?(:aws)
        end

        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

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

        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

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

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
ls-trace-0.1.2 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.29.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.26.1 lib/ddtrace/contrib/aws/patcher.rb
ls-trace-0.1.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.29.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.28.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.27.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.26.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.25.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.25.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.24.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.23.3 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.23.2 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.23.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.23.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.22.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.21.2 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.21.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.21.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.20.0 lib/ddtrace/contrib/aws/patcher.rb