Sha256: 5bc1a9401718bf08dc651b56d161e45fd1ad34d6bfab125bbbf8de67b79303c9

Contents?: true

Size: 1.55 KB

Versions: 27

Compression:

Stored size: 1.55 KB

Contents

module Datadog
  module Contrib
    module Aws
      AGENT = 'aws-sdk-ruby'.freeze
      RESOURCE = 'aws.command'.freeze

      # Responsible for hooking the instrumentation into aws-sdk
      module Patcher
        include Base
        register_as :aws, auto_patch: true
        option :service_name, default: 'aws'

        @patched = false

        class << self
          def patch
            return @patched if patched? || !defined?(Seahorse::Client::Base)

            require 'ddtrace/ext/app_types'
            require 'ddtrace/contrib/aws/parsed_context'
            require 'ddtrace/contrib/aws/instrumentation'
            require 'ddtrace/contrib/aws/services'

            add_pin
            add_plugin(Seahorse::Client::Base, *loaded_constants)

            @patched = true
          rescue => e
            Datadog::Tracer.log.error("Unable to apply AWS integration: #{e}")
            @patched
          end

          def patched?
            @patched
          end

          private

          def add_pin
            Pin
              .new(get_option(:service_name), app: 'aws', app_type: Ext::AppTypes::WEB)
              .onto(::Aws)
          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
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
ddtrace-0.16.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.15.0.internaltracinfeature1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.16.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.14.2.disableprotocolversion4 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.15.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.14.2.withoutpriorityparsing1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.14.2 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.14.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.15.0.beta1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.14.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.14.0.rc1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.13.2 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.14.0.beta2 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.14.0.beta1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.13.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.13.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.12.1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.13.0.beta1 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.12.0 lib/ddtrace/contrib/aws/patcher.rb
ddtrace-0.12.0.rc1 lib/ddtrace/contrib/aws/patcher.rb