call

in lib/aws-xray-sdk/facets/aws_sdk.rb [18:67]


      def call(context)
        operation = context.operation_name
        service_name = context.client.class.api.metadata['serviceAbbreviation'] ||
                       context.client.class.to_s.split('::')[1]
        if skip?(service_name, operation)
          return super
        end

        recorder = Aws.config[:xray_recorder]
        if recorder.nil? || recorder.current_entity.nil?
          return super
        end

        recorder.capture(service_name, namespace: 'aws') do |subsegment|
          
          context.http_request.headers[TRACE_HEADER] = prep_header_str entity: subsegment
          response = @handler.call(context)
          http_response = context.http_response
          resp_meta = {
            status: http_response.status_code,
            content_length: http_response.headers['content-length'].to_i
          }
          aws = {
            
            operation: sanitize_op_name(operation),
            region: context.client.config.region,
            retries: context.retries,
            request_id: http_response.headers['x-amzn-requestid']
          }
          
          if service_name == 'S3'
            aws[:id_2] = http_response.headers['x-amz-id-2']
          end

          operation_h = AwsParams.whitelist[:services]
                                 .fetch(service_name.to_sym, {})
                                 .fetch(:operations, {})[operation]
          unless operation_h.nil?
            params_capture req_params: context.params, resp_params: response.to_h,
                           capture: operation_h, meta: aws
          end
          subsegment.aws = aws
          if err = response.error
            subsegment.add_exception exception: err, remote: true
          end
          subsegment.merge_http_response response: resp_meta
          response
        end
      end