Class: Aws::Plugins::ClientMetricsSendPlugin::AttemptHandler Private

Inherits:
Seahorse::Client::Handler show all
Defined in:
lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Handler

#handler

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Handler

#initialize, #inspect

Constructor Details

This class inherits a constructor from Seahorse::Client::Handler

Instance Method Details

#call(context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb', line 29

def call(context)
  request_metrics = context.[:client_metrics]
  attempt_opts = {
    timestamp: DateTime.now.strftime('%Q').to_i,
    fqdn: context.http_request.endpoint.host,
    region: context.config.region,
    user_agent: context.http_request.headers["user-agent"],
  }
  # It will generally cause an error, but it is semantically valid for
  # credentials to not exist.
  if context.config.credentials
    attempt_opts[:access_key] =
      context.config.credentials.credentials.access_key_id
    attempt_opts[:session_token] =
      context.config.credentials.credentials.session_token
  end
  call_attempt = request_metrics.build_call_attempt(attempt_opts)
  context.[:current_call_attempt] = call_attempt

  resp = @handler.call(context)
  if context.[:redirect_region]
    call_attempt.region = context.[:redirect_region]
  end
  headers = context.http_response.headers
  if headers.include?("x-amz-id-2")
    call_attempt.x_amz_id_2 = headers["x-amz-id-2"]
  end
  if headers.include?("x-amz-request-id")
    call_attempt.x_amz_request_id = headers["x-amz-request-id"]
  end
  if headers.include?("x-amzn-request-id")
    call_attempt.x_amzn_request_id = headers["x-amzn-request-id"]
  end
  call_attempt.http_status_code = context.http_response.status_code
  if e = resp.error
    e_name = _extract_error_name(e)
    e_msg = e.message
    call_attempt.aws_exception = "#{e_name}"
    call_attempt.aws_exception_msg = "#{e_msg}"
  end
  request_metrics.add_call_attempt(call_attempt)
  resp
end