Class: OpenTelemetry::Instrumentation::AwsSdk::Handler

Inherits:
Seahorse::Client::Handler
  • Object
show all
Defined in:
lib/opentelemetry/instrumentation/aws_sdk/handler.rb

Overview

This handler supports specifically supports V2 and V3 prior to Observability support released on 2024-09-03.

Instance Method Summary collapse

Instance Method Details

#call(context) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler.rb', line 13

def call(context)
  return super unless context

  service_id = HandlerHelper.service_id(context, legacy: true)
  client_method = HandlerHelper.client_method(service_id, context)

  tracer.in_span(
    HandlerHelper.span_name(context, client_method, service_id, legacy: true),
    attributes: HandlerHelper.span_attributes(context, client_method, service_id, legacy: true),
    kind: HandlerHelper.span_kind(client_method, service_id)
  ) do |span|
    MessagingHelper.inject_context_if_supported(context, client_method, service_id)

    if HandlerHelper.instrumentation_config[:suppress_internal_instrumentation]
      OpenTelemetry::Common::Utilities.untraced { super }
    else
      super
    end.tap do |response|
      span.set_attribute(
        OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE,
        context.http_response.status_code
      )

      if (err = response.error)
        span.record_exception(err)
        span.status = Trace::Status.error(err.to_s)
      end
    end
  end
end