Sha256: 60b567c9a0daaba8cfa3f2f95ceb2fb3235a4aceb1546d497c88e34e8fde3ba1

Contents?: true

Size: 1.39 KB

Versions: 17

Compression:

Stored size: 1.39 KB

Contents

module Datadog
  module Contrib
    module Aws
      # A Seahorse::Client::Plugin that enables instrumentation for all AWS services
      class Instrumentation < Seahorse::Client::Plugin
        def add_handlers(handlers, _)
          handlers.add(Handler, step: :validate)
        end
      end

      # Generates Spans for all interactions with AWS
      class Handler < Seahorse::Client::Handler
        def call(context)
          pin = Datadog::Pin.get_from(::Aws)

          return @handler.call(context) unless pin && pin.enabled?

          pin.tracer.trace(RESOURCE) do |span|
            result = @handler.call(context)
            annotate!(span, pin, ParsedContext.new(context))
            result
          end
        end

        private

        def annotate!(span, pin, context)
          span.service = pin.service
          span.span_type = pin.app_type
          span.name = RESOURCE
          span.resource = context.safely(:resource)
          span.set_tag('aws.agent', AGENT)
          span.set_tag('aws.operation', context.safely(:operation))
          span.set_tag('aws.region', context.safely(:region))
          span.set_tag('path', context.safely(:path))
          span.set_tag('host', context.safely(:host))
          span.set_tag(Ext::HTTP::METHOD, context.safely(:http_method))
          span.set_tag(Ext::HTTP::STATUS_CODE, context.safely(:status_code))
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

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