aws-sdk-core 3.197.0 → 3.220.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +297 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults/default_configuration.rb +1 -2
  5. data/lib/aws-defaults.rb +4 -1
  6. data/lib/aws-sdk-core/arn.rb +1 -3
  7. data/lib/aws-sdk-core/assume_role_credentials.rb +12 -5
  8. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +13 -7
  9. data/lib/aws-sdk-core/binary/decode_handler.rb +3 -4
  10. data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
  11. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
  12. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
  13. data/lib/aws-sdk-core/cbor/decoder.rb +308 -0
  14. data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
  15. data/lib/aws-sdk-core/cbor.rb +53 -0
  16. data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
  17. data/lib/aws-sdk-core/client_stubs.rb +8 -7
  18. data/lib/aws-sdk-core/credential_provider_chain.rb +13 -6
  19. data/lib/aws-sdk-core/credentials.rb +13 -6
  20. data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
  21. data/lib/aws-sdk-core/endpoints/matchers.rb +6 -9
  22. data/lib/aws-sdk-core/endpoints.rb +74 -18
  23. data/lib/aws-sdk-core/error_handler.rb +41 -0
  24. data/lib/aws-sdk-core/errors.rb +9 -0
  25. data/lib/aws-sdk-core/json/error_handler.rb +8 -9
  26. data/lib/aws-sdk-core/json/handler.rb +6 -6
  27. data/lib/aws-sdk-core/json/json_engine.rb +3 -1
  28. data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
  29. data/lib/aws-sdk-core/json/parser.rb +2 -0
  30. data/lib/aws-sdk-core/json.rb +43 -14
  31. data/lib/aws-sdk-core/log/param_filter.rb +2 -2
  32. data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
  33. data/lib/aws-sdk-core/log.rb +10 -0
  34. data/lib/aws-sdk-core/param_validator.rb +1 -1
  35. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
  36. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +332 -169
  37. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +7 -3
  38. data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
  39. data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -8
  40. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
  41. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
  42. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
  43. data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
  44. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +4 -3
  45. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +5 -1
  46. data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
  47. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +74 -25
  48. data/lib/aws-sdk-core/plugins/retry_errors.rb +0 -1
  49. data/lib/aws-sdk-core/plugins/sign.rb +13 -11
  50. data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
  51. data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
  52. data/lib/aws-sdk-core/plugins/stub_responses.rb +29 -2
  53. data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
  54. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
  55. data/lib/aws-sdk-core/plugins/user_agent.rb +26 -8
  56. data/lib/aws-sdk-core/plugins.rb +39 -0
  57. data/lib/aws-sdk-core/process_credentials.rb +47 -28
  58. data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
  59. data/lib/aws-sdk-core/query/handler.rb +4 -4
  60. data/lib/aws-sdk-core/query.rb +2 -1
  61. data/lib/aws-sdk-core/resources.rb +8 -0
  62. data/lib/aws-sdk-core/rest/{request/content_type.rb → content_type_handler.rb} +1 -1
  63. data/lib/aws-sdk-core/rest/handler.rb +3 -4
  64. data/lib/aws-sdk-core/rest/request/endpoint.rb +3 -1
  65. data/lib/aws-sdk-core/rest/request/headers.rb +2 -2
  66. data/lib/aws-sdk-core/rest.rb +1 -1
  67. data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
  68. data/lib/aws-sdk-core/rpc_v2/cbor_engine.rb +18 -0
  69. data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +47 -0
  70. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +85 -0
  71. data/lib/aws-sdk-core/rpc_v2/handler.rb +79 -0
  72. data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
  73. data/lib/aws-sdk-core/rpc_v2.rb +69 -0
  74. data/lib/aws-sdk-core/shared_config.rb +7 -2
  75. data/lib/aws-sdk-core/shared_credentials.rb +0 -7
  76. data/lib/aws-sdk-core/sso_credentials.rb +2 -1
  77. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
  78. data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
  79. data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
  80. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
  81. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
  82. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
  83. data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +39 -0
  84. data/lib/aws-sdk-core/stubbing.rb +22 -0
  85. data/lib/aws-sdk-core/telemetry/base.rb +177 -0
  86. data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
  87. data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
  88. data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
  89. data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
  90. data/lib/aws-sdk-core/telemetry.rb +78 -0
  91. data/lib/aws-sdk-core/waiters/poller.rb +9 -4
  92. data/lib/aws-sdk-core/xml/error_handler.rb +11 -37
  93. data/lib/aws-sdk-core/xml/parser.rb +2 -6
  94. data/lib/aws-sdk-core.rb +82 -108
  95. data/lib/aws-sdk-sso/client.rb +99 -37
  96. data/lib/aws-sdk-sso/client_api.rb +7 -0
  97. data/lib/aws-sdk-sso/endpoint_parameters.rb +9 -6
  98. data/lib/aws-sdk-sso/endpoint_provider.rb +14 -18
  99. data/lib/aws-sdk-sso/endpoints.rb +2 -54
  100. data/lib/aws-sdk-sso/plugins/endpoints.rb +19 -20
  101. data/lib/aws-sdk-sso/types.rb +1 -0
  102. data/lib/aws-sdk-sso.rb +15 -11
  103. data/lib/aws-sdk-ssooidc/client.rb +123 -55
  104. data/lib/aws-sdk-ssooidc/client_api.rb +5 -0
  105. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +9 -6
  106. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +14 -18
  107. data/lib/aws-sdk-ssooidc/endpoints.rb +2 -54
  108. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +19 -20
  109. data/lib/aws-sdk-ssooidc/types.rb +21 -15
  110. data/lib/aws-sdk-ssooidc.rb +15 -11
  111. data/lib/aws-sdk-sts/client.rb +307 -89
  112. data/lib/aws-sdk-sts/client_api.rb +28 -2
  113. data/lib/aws-sdk-sts/customizations.rb +5 -1
  114. data/lib/aws-sdk-sts/endpoint_parameters.rb +10 -9
  115. data/lib/aws-sdk-sts/endpoint_provider.rb +33 -38
  116. data/lib/aws-sdk-sts/endpoints.rb +2 -118
  117. data/lib/aws-sdk-sts/errors.rb +16 -0
  118. data/lib/aws-sdk-sts/plugins/endpoints.rb +19 -28
  119. data/lib/aws-sdk-sts/types.rb +171 -28
  120. data/lib/aws-sdk-sts.rb +15 -11
  121. data/lib/seahorse/client/base.rb +17 -7
  122. data/lib/seahorse/client/h2/handler.rb +13 -3
  123. data/lib/seahorse/client/handler.rb +1 -1
  124. data/lib/seahorse/client/net_http/connection_pool.rb +10 -2
  125. data/lib/seahorse/client/net_http/handler.rb +21 -9
  126. data/lib/seahorse/client/plugins/endpoint.rb +0 -1
  127. data/lib/seahorse/client/plugins/net_http.rb +9 -0
  128. data/lib/seahorse/client/request_context.rb +8 -1
  129. data/lib/seahorse/client/response.rb +2 -0
  130. data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
  131. data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
  132. data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
  133. data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
  134. metadata +62 -18
  135. /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
  136. /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
  137. /data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +0 -0
  138. /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
  139. /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Telemetry
5
+ # No-op implementation for {TelemetryProviderBase}.
6
+ class NoOpTelemetryProvider < TelemetryProviderBase
7
+ def initialize
8
+ super(
9
+ tracer_provider: NoOpTracerProvider.new,
10
+ context_manager: NoOpContextManager.new
11
+ )
12
+ end
13
+ end
14
+
15
+ # No-op implementation for {TracerProviderBase}.
16
+ class NoOpTracerProvider < TracerProviderBase
17
+ def tracer(name = nil)
18
+ @tracer ||= NoOpTracer.new
19
+ end
20
+ end
21
+
22
+ # No-op implementation for {TracerBase}.
23
+ class NoOpTracer < TracerBase
24
+ def start_span(name, with_parent: nil, attributes: nil, kind: nil)
25
+ NoOpSpan.new
26
+ end
27
+
28
+ def in_span(name, attributes: nil, kind: nil)
29
+ yield NoOpSpan.new
30
+ end
31
+
32
+ def current_span
33
+ NoOpSpan.new
34
+ end
35
+ end
36
+
37
+ # No-op implementation for {SpanBase}.
38
+ class NoOpSpan < SpanBase
39
+ def set_attribute(key, value)
40
+ self
41
+ end
42
+ alias []= set_attribute
43
+
44
+ def add_attributes(attributes)
45
+ self
46
+ end
47
+
48
+ def add_event(name, attributes: nil)
49
+ self
50
+ end
51
+
52
+ def status=(status); end
53
+
54
+ def finish(end_timestamp: nil)
55
+ self
56
+ end
57
+
58
+ def record_exception(exception, attributes: nil); end
59
+ end
60
+
61
+ # No-op implementation for {ContextManagerBase}.
62
+ class NoOpContextManager < ContextManagerBase
63
+ def current; end
64
+
65
+ def attach(context); end
66
+
67
+ def detach(token); end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,235 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Telemetry
5
+ # OTelProvider allows to emit telemetry data based on OpenTelemetry.
6
+ #
7
+ # To use this provider, require the `opentelemetry-sdk` gem and then,
8
+ # pass in an instance of a `Aws::Telemetry::OTelProvider` as the
9
+ # telemetry provider in the client config.
10
+ #
11
+ # @example Configuration
12
+ # require 'opentelemetry-sdk'
13
+ #
14
+ # # sets up the OpenTelemetry SDK with their config defaults
15
+ # OpenTelemetry::SDK.configure
16
+ #
17
+ # otel_provider = Aws::Telemetry::OTelProvider.new
18
+ # client = Aws::S3::Client.new(telemetry_provider: otel_provider)
19
+ #
20
+ # OpenTelemetry supports many ways to export your telemetry data.
21
+ # See {https://opentelemetry.io/docs/languages/ruby/exporters here} for
22
+ # more information.
23
+ #
24
+ # @example Exporting via console
25
+ # require 'opentelemetry-sdk'
26
+ #
27
+ # ENV['OTEL_TRACES_EXPORTER'] ||= 'console'
28
+ #
29
+ # # configures the OpenTelemetry SDK with defaults
30
+ # OpenTelemetry::SDK.configure
31
+ #
32
+ # otel_provider = Aws::Telemetry::OTelProvider.new
33
+ # client = Aws::S3::Client.new(telemetry_provider: otel_provider)
34
+ class OTelProvider < TelemetryProviderBase
35
+ def initialize
36
+ unless otel_loaded?
37
+ raise ArgumentError,
38
+ 'Requires the `opentelemetry-sdk` gem to use OTel Provider.'
39
+ end
40
+ super(
41
+ tracer_provider: OTelTracerProvider.new,
42
+ context_manager: OTelContextManager.new
43
+ )
44
+ end
45
+
46
+ private
47
+
48
+ def otel_loaded?
49
+ if @use_otel.nil?
50
+ @use_otel =
51
+ begin
52
+ require 'opentelemetry-sdk'
53
+ true
54
+ rescue LoadError, NameError
55
+ false
56
+ end
57
+ end
58
+ @use_otel
59
+ end
60
+ end
61
+
62
+ # OpenTelemetry-based {TracerProviderBase}, an entry point for
63
+ # creating Tracer instances.
64
+ class OTelTracerProvider < TracerProviderBase
65
+ def initialize
66
+ super
67
+ @tracer_provider = OpenTelemetry.tracer_provider
68
+ end
69
+
70
+ # Returns a Tracer instance.
71
+ #
72
+ # @param [optional String] name Tracer name
73
+ # @return [Aws::Telemetry::OTelTracer]
74
+ def tracer(name = nil)
75
+ OTelTracer.new(@tracer_provider.tracer(name))
76
+ end
77
+ end
78
+
79
+ # OpenTelemetry-based {TracerBase}, responsible for creating spans.
80
+ class OTelTracer < TracerBase
81
+ def initialize(tracer)
82
+ super()
83
+ @tracer = tracer
84
+ end
85
+
86
+ # Used when a caller wants to manage the activation/deactivation and
87
+ # lifecycle of the Span and its parent manually.
88
+ #
89
+ # @param [String] name Span name
90
+ # @param [Object] with_parent Parent Context
91
+ # @param [Hash] attributes Attributes to attach to the span
92
+ # @param [Aws::Telemetry::SpanKind] kind Type of Span
93
+ # @return [Aws::Telemetry::OTelSpan]
94
+ def start_span(name, with_parent: nil, attributes: nil, kind: nil)
95
+ span = @tracer.start_span(
96
+ name,
97
+ with_parent: with_parent,
98
+ attributes: attributes,
99
+ kind: kind
100
+ )
101
+ OTelSpan.new(span)
102
+ end
103
+
104
+ # A helper for the default use-case of extending the current trace
105
+ # with a span.
106
+ # On exit, the Span that was active before calling this method will
107
+ # be reactivated. If an exception occurs during the execution of the
108
+ # provided block, it will be recorded on the span and re-raised.
109
+ #
110
+ # @param [String] name Span name
111
+ # @param [Hash] attributes Attributes to attach to the span
112
+ # @param [Aws::Telemetry::SpanKind] kind Type of Span
113
+ # @return [Aws::Telemetry::OTelSpan]
114
+ def in_span(name, attributes: nil, kind: nil, &block)
115
+ @tracer.in_span(name, attributes: attributes, kind: kind) do |span|
116
+ block.call(OTelSpan.new(span))
117
+ end
118
+ end
119
+
120
+ # Returns the current active span.
121
+ #
122
+ # @return [Aws::Telemetry::OTelSpan]
123
+ def current_span
124
+ OTelSpan.new(OpenTelemetry::Trace.current_span)
125
+ end
126
+ end
127
+
128
+ # OpenTelemetry-based {SpanBase}, represents a single operation
129
+ # within a trace.
130
+ class OTelSpan < SpanBase
131
+ def initialize(span)
132
+ super()
133
+ @span = span
134
+ end
135
+
136
+ # Set attribute.
137
+ #
138
+ # @param [String] key
139
+ # @param [String, Boolean, Numeric, Array<String, Numeric, Boolean>] value
140
+ # Value must be non-nil and (array of) string, boolean or numeric type.
141
+ # Array values must not contain nil elements and all elements must be of
142
+ # the same basic type (string, numeric, boolean)
143
+ # @return [self] returns itself
144
+ def set_attribute(key, value)
145
+ @span.set_attribute(key, value)
146
+ end
147
+ alias []= set_attribute
148
+
149
+ # Add attributes.
150
+ #
151
+ # @param [Hash{String => String, Numeric, Boolean, Array<String, Numeric,
152
+ # Boolean>}] attributes Values must be non-nil and (array of) string,
153
+ # boolean or numeric type. Array values must not contain nil elements
154
+ # and all elements must be of the same basic type (string, numeric,
155
+ # boolean)
156
+ # @return [self] returns itself
157
+ def add_attributes(attributes)
158
+ @span.add_attributes(attributes)
159
+ end
160
+
161
+ # Add event to a Span.
162
+ #
163
+ # @param [String] name Name of the event
164
+ # @param [Hash{String => String, Numeric, Boolean, Array<String,
165
+ # Numeric, Boolean>}] attributes Values must be non-nil and (array of)
166
+ # string, boolean or numeric type. Array values must not contain nil
167
+ # elements and all elements must be of the same basic type (string,
168
+ # numeric, boolean)
169
+ # @return [self] returns itself
170
+ def add_event(name, attributes: nil)
171
+ @span.add_event(name, attributes: attributes)
172
+ end
173
+
174
+ # Sets the Span status.
175
+ #
176
+ # @param [Aws::Telemetry::Status] status The new status, which
177
+ # overrides the default Span status, which is `OK`
178
+ # @return [void]
179
+ def status=(status)
180
+ @span.status = status
181
+ end
182
+
183
+ # Finishes the Span.
184
+ #
185
+ # @param [Time] end_timestamp End timestamp for the span
186
+ # @return [self] returns itself
187
+ def finish(end_timestamp: nil)
188
+ @span.finish(end_timestamp: end_timestamp)
189
+ end
190
+
191
+ # Record an exception during the execution of this span. Multiple
192
+ # exceptions can be recorded on a span.
193
+ #
194
+ # @param [Exception] exception The exception to be recorded
195
+ # @param [Hash{String => String, Numeric, Boolean, Array<String,
196
+ # Numeric, Boolean>}] attributes One or more key:value pairs, where the
197
+ # keys must be strings and the values may be (array of) string, boolean
198
+ # or numeric type
199
+ # @return [void]
200
+ def record_exception(exception, attributes: nil)
201
+ @span.record_exception(exception, attributes: attributes)
202
+ end
203
+ end
204
+
205
+ # OpenTelemetry-based {ContextManagerBase}, manages context and
206
+ # used to return the current context within a trace.
207
+ class OTelContextManager < ContextManagerBase
208
+ # Returns current context.
209
+ #
210
+ # @return [Context]
211
+ def current
212
+ OpenTelemetry::Context.current
213
+ end
214
+
215
+ # Associates a Context with the caller’s current execution unit.
216
+ # Returns a token to be used with the matching call to detach.
217
+ #
218
+ # @param [Context] context The new context
219
+ # @return [Object] token A token to be used when detaching
220
+ def attach(context)
221
+ OpenTelemetry::Context.attach(context)
222
+ end
223
+
224
+ # Restore the previous Context associated with the current
225
+ # execution unit to the value it had before attaching a
226
+ # specified Context.
227
+ #
228
+ # @param [Object] token The token provided by matching the call to attach
229
+ # @return [Boolean] `True` if the calls matched, `False` otherwise
230
+ def detach(token)
231
+ OpenTelemetry::Context.detach(token)
232
+ end
233
+ end
234
+ end
235
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Telemetry
5
+ module SpanKind
6
+ # Default. Represents an internal operation within an application.
7
+ INTERNAL = :internal
8
+
9
+ # Represents handling synchronous network requests.
10
+ SERVER = :server
11
+
12
+ # Represents a request to some remote service.
13
+ CLIENT = :client
14
+
15
+ # Represents a child of an asynchronous `PRODUCER` request.
16
+ CONSUMER = :consumer
17
+
18
+ # Represents an asynchronous request.
19
+ PRODUCER = :producer
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Telemetry
5
+ # Represents the status of a finished span.
6
+ class SpanStatus
7
+ class << self
8
+ private :new
9
+
10
+ # Returns a newly created {SpanStatus} with code, `UNSET`
11
+ # and an optional description.
12
+ #
13
+ # @param [optional String] description
14
+ # @return [SpanStatus]
15
+ def unset(description = '')
16
+ new(UNSET, description: description)
17
+ end
18
+
19
+ # Returns a newly created {SpanStatus} with code, `OK`
20
+ # and an optional description.
21
+ #
22
+ # @param [optional String] description
23
+ # @return [SpanStatus]
24
+ def ok(description = '')
25
+ new(OK, description: description)
26
+ end
27
+
28
+ # Returns a newly created {SpanStatus} with code, `ERROR`
29
+ # and an optional description.
30
+ #
31
+ # @param [optional String] description
32
+ # @return [SpanStatus]
33
+ def error(description = '')
34
+ new(ERROR, description: description)
35
+ end
36
+ end
37
+
38
+ def initialize(code, description: '')
39
+ @code = code
40
+ @description = description
41
+ end
42
+
43
+ # @return [Integer] code
44
+ attr_reader :code
45
+
46
+ # @return [String] description
47
+ attr_reader :description
48
+
49
+ # The operation completed successfully.
50
+ OK = 0
51
+
52
+ # The default status.
53
+ UNSET = 1
54
+
55
+ # An error.
56
+ ERROR = 2
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'telemetry/base'
4
+ require_relative 'telemetry/no_op'
5
+ require_relative 'telemetry/otel'
6
+ require_relative 'telemetry/span_kind'
7
+ require_relative 'telemetry/span_status'
8
+
9
+ module Aws
10
+ # Observability is the extent to which a system's current state can be
11
+ # inferred from the data it emits. The data emitted is commonly referred
12
+ # as Telemetry. The AWS SDK for Ruby currently supports traces as
13
+ # a telemetry signal.
14
+ #
15
+ # A telemetry provider is used to emit telemetry data. By default, the
16
+ # {NoOpTelemetryProvider} will not record or emit any telemetry data.
17
+ # The SDK currently supports OpenTelemetry (OTel) as a provider. See
18
+ # {OTelProvider} for more information.
19
+ #
20
+ # If a provider isn't supported, you can implement your own provider by
21
+ # inheriting the following base classes and implementing the interfaces
22
+ # defined:
23
+ # * {TelemetryProviderBase}
24
+ # * {ContextManagerBase}
25
+ # * {TracerProviderBase}
26
+ # * {TracerBase}
27
+ # * {SpanBase}
28
+ module Telemetry
29
+ class << self
30
+ # @api private
31
+ def module_to_tracer_name(module_name)
32
+ "#{module_name.gsub('::', '.')}.client".downcase
33
+ end
34
+
35
+ # @api private
36
+ def http_request_attrs(context)
37
+ {
38
+ 'http.method' => context.http_request.http_method,
39
+ 'net.protocol.name' => 'http'
40
+ }.tap do |h|
41
+ h['net.protocol.version'] =
42
+ if context.client.is_a? Seahorse::Client::AsyncBase
43
+ '2'
44
+ else
45
+ Net::HTTP::HTTPVersion
46
+ end
47
+
48
+ unless context.config.stub_responses
49
+ h['net.peer.name'] = context.http_request.endpoint.host
50
+ h['net.peer.port'] = context.http_request.endpoint.port.to_s
51
+ end
52
+
53
+ if context.http_request.headers.key?('Content-Length')
54
+ h['http.request_content_length'] =
55
+ context.http_request.headers['Content-Length']
56
+ end
57
+ end
58
+ end
59
+
60
+ # @api private
61
+ def http_response_attrs(context)
62
+ {
63
+ 'http.status_code' => context.http_response.status_code.to_s
64
+ }.tap do |h|
65
+ if context.http_response.headers.key?('Content-Length')
66
+ h['http.response_content_length'] =
67
+ context.http_response.headers['Content-Length']
68
+ end
69
+
70
+ if context.http_response.headers.key?('x-amz-request-id')
71
+ h['aws.request_id'] =
72
+ context.http_response.headers['x-amz-request-id']
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -29,7 +29,7 @@ module Aws
29
29
  # * `:retry` - The waiter may be retried.
30
30
  # * `:error` - The waiter encountered an un-expected error.
31
31
  #
32
- # @example A trival (bad) example of a waiter that polls indefinetly.
32
+ # @example A trivial (bad) example of a waiter that polls indefinetly.
33
33
  #
34
34
  # loop do
35
35
  #
@@ -96,8 +96,13 @@ module Aws
96
96
  end
97
97
 
98
98
  def matches_error?(acceptor, response)
99
- Aws::Errors::ServiceError === response.error &&
100
- response.error.code == acceptor['expected'].delete('.')
99
+ case acceptor['expected']
100
+ when 'false' then response.error.nil?
101
+ when 'true' then !response.error.nil?
102
+ else
103
+ response.error.is_a?(Aws::Errors::ServiceError) &&
104
+ response.error.code == acceptor['expected'].delete('.')
105
+ end
101
106
  end
102
107
 
103
108
  def path(acceptor)
@@ -107,7 +112,7 @@ module Aws
107
112
  def non_empty_array(acceptor, response, &block)
108
113
  if response.data
109
114
  values = JMESPath.search(path(acceptor), response.data)
110
- Array === values && values.count > 0 ? yield(values) : false
115
+ values.is_a?(Array) && values.count > 0 ? yield(values) : false
111
116
  else
112
117
  false
113
118
  end
@@ -4,7 +4,7 @@ require 'cgi'
4
4
 
5
5
  module Aws
6
6
  module Xml
7
- class ErrorHandler < Seahorse::Client::Handler
7
+ class ErrorHandler < Aws::ErrorHandler
8
8
 
9
9
  def call(context)
10
10
  @handler.call(context).on(300..599) do |response|
@@ -15,32 +15,19 @@ module Aws
15
15
 
16
16
  private
17
17
 
18
- def error(context)
19
- body = context.http_response.body_contents
20
- if body.empty?
21
- code = http_status_error_code(context)
22
- message = ''
23
- data = EmptyStructure.new
24
- else
25
- code, message, data = extract_error(body, context)
26
- end
27
- context[:request_id] = request_id(body)
28
- errors_module = context.client.class.errors_module
29
- errors_module.error_class(code).new(context, message, data)
30
- end
31
-
32
18
  def extract_error(body, context)
19
+ context[:request_id] = request_id(body)
33
20
  code = error_code(body, context)
34
21
  [
35
22
  code,
36
23
  error_message(body),
37
- error_data(context, code)
24
+ error_data(context, body, code)
38
25
  ]
39
26
  end
40
27
 
41
- def error_data(context, code)
28
+ def error_data(context, body, code)
42
29
  data = EmptyStructure.new
43
- if error_rules = context.operation.errors
30
+ if (error_rules = context.operation.errors)
44
31
  error_rules.each do |rule|
45
32
  # query protocol may have custom error code
46
33
  # reference: https://smithy.io/2.0/aws/protocols/aws-query-protocol.html#error-code-resolution
@@ -48,7 +35,7 @@ module Aws
48
35
  match = (code == error_shape_code || code == rule.shape.name)
49
36
  next unless match && rule.shape.members.any?
50
37
 
51
- data = parse_error_data(rule, context.http_response.body_contents)
38
+ data = parse_error_data(rule, body)
52
39
  # supporting HTTP bindings
53
40
  apply_error_headers(rule, context, data)
54
41
  end
@@ -62,7 +49,7 @@ module Aws
62
49
  # errors may nested under <Errors><Error>structure_data</Error></Errors>
63
50
  # Or may be flat and under <Error>structure_data</Error>
64
51
  body = body.tr("\n", '')
65
- if matches = body.match(/<Error>(.+?)<\/Error>/)
52
+ if (matches = body.match(/<Error>(.+?)<\/Error>/))
66
53
  Parser.new(rule).parse("<#{rule.shape.name}>#{matches[1]}</#{rule.shape.name}>")
67
54
  else
68
55
  EmptyStructure.new
@@ -75,28 +62,15 @@ module Aws
75
62
  end
76
63
 
77
64
  def error_code(body, context)
78
- if matches = body.match(/<Code>(.+?)<\/Code>/)
65
+ if (matches = body.match(/<Code>(.+?)<\/Code>/))
79
66
  remove_prefix(unescape(matches[1]), context)
80
67
  else
81
68
  http_status_error_code(context)
82
69
  end
83
70
  end
84
71
 
85
- def http_status_error_code(context)
86
- status_code = context.http_response.status_code
87
- {
88
- 302 => 'MovedTemporarily',
89
- 304 => 'NotModified',
90
- 400 => 'BadRequest',
91
- 403 => 'Forbidden',
92
- 404 => 'NotFound',
93
- 412 => 'PreconditionFailed',
94
- 413 => 'RequestEntityTooLarge',
95
- }[status_code] || "Http#{status_code}Error"
96
- end
97
-
98
72
  def remove_prefix(error_code, context)
99
- if prefix = context.config.api.metadata['errorPrefix']
73
+ if (prefix = context.config.api.metadata['errorPrefix'])
100
74
  error_code.sub(/^#{prefix}/, '')
101
75
  else
102
76
  error_code
@@ -104,7 +78,7 @@ module Aws
104
78
  end
105
79
 
106
80
  def error_message(body)
107
- if matches = body.match(/<Message>(.+?)<\/Message>/m)
81
+ if (matches = body.match(/<Message>(.+?)<\/Message>/m))
108
82
  unescape(matches[1])
109
83
  else
110
84
  ''
@@ -112,7 +86,7 @@ module Aws
112
86
  end
113
87
 
114
88
  def request_id(body)
115
- if matches = body.match(/<RequestId>(.+?)<\/RequestId>/m)
89
+ if (matches = body.match(/<RequestId>(.+?)<\/RequestId>/m))
116
90
  matches[1]
117
91
  end
118
92
  end
@@ -5,7 +5,6 @@ module Aws
5
5
  module Xml
6
6
  # A SAX-style XML parser that uses a shape context to handle types.
7
7
  class Parser
8
-
9
8
  # @param [Seahorse::Model::ShapeRef] rules
10
9
  def initialize(rules, options = {})
11
10
  @rules = rules
@@ -47,8 +46,7 @@ module Aws
47
46
  # * :libxml
48
47
  # * :nokogiri
49
48
  # * :rexml
50
- #
51
- def engine= engine
49
+ def engine=(engine)
52
50
  @engine = Class === engine ? engine : load_engine(engine)
53
51
  end
54
52
 
@@ -60,7 +58,6 @@ module Aws
60
58
  # * {LibxmlEngine}
61
59
  # * {NokogiriEngine}
62
60
  # * {RexmlEngine}
63
- #
64
61
  def engine
65
62
  set_default_engine unless @engine
66
63
  @engine
@@ -80,7 +77,7 @@ module Aws
80
77
  private
81
78
 
82
79
  def load_engine(name)
83
- require "aws-sdk-core/xml/parser/engines/#{name}"
80
+ require "aws-sdk-core/xml/parser/#{name}_engine"
84
81
  const_name = name[0].upcase + name[1..-1] + 'Engine'
85
82
  const_get(const_name)
86
83
  end
@@ -94,7 +91,6 @@ module Aws
94
91
  end
95
92
 
96
93
  set_default_engine
97
-
98
94
  end
99
95
  end
100
96
  end