aws-sdk-core 3.181.0 → 3.209.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +413 -0
- data/VERSION +1 -1
- data/lib/aws-defaults.rb +4 -1
- data/lib/aws-sdk-core/assume_role_credentials.rb +12 -5
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +13 -7
- data/lib/aws-sdk-core/binary/decode_handler.rb +3 -9
- data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
- data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
- data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
- data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
- data/lib/aws-sdk-core/cbor/cbor_engine.rb +19 -0
- data/lib/aws-sdk-core/cbor/decoder.rb +310 -0
- data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
- data/lib/aws-sdk-core/cbor.rb +106 -0
- data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
- data/lib/aws-sdk-core/client_stubs.rb +18 -14
- data/lib/aws-sdk-core/credential_provider.rb +1 -1
- data/lib/aws-sdk-core/credential_provider_chain.rb +13 -6
- data/lib/aws-sdk-core/credentials.rb +13 -6
- data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
- data/lib/aws-sdk-core/ecs_credentials.rb +78 -11
- data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
- data/lib/aws-sdk-core/endpoints/matchers.rb +18 -10
- data/lib/aws-sdk-core/endpoints.rb +74 -18
- data/lib/aws-sdk-core/error_handler.rb +41 -0
- data/lib/aws-sdk-core/errors.rb +12 -3
- data/lib/aws-sdk-core/event_emitter.rb +0 -16
- data/lib/aws-sdk-core/instance_profile_credentials.rb +55 -32
- data/lib/aws-sdk-core/json/builder.rb +8 -1
- data/lib/aws-sdk-core/json/error_handler.rb +15 -10
- data/lib/aws-sdk-core/json/handler.rb +12 -6
- data/lib/aws-sdk-core/json/json_engine.rb +3 -1
- data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
- data/lib/aws-sdk-core/json/parser.rb +33 -3
- data/lib/aws-sdk-core/json.rb +43 -14
- data/lib/aws-sdk-core/log/param_filter.rb +2 -2
- data/lib/aws-sdk-core/log.rb +10 -0
- data/lib/aws-sdk-core/lru_cache.rb +75 -0
- data/lib/aws-sdk-core/pageable_response.rb +1 -1
- data/lib/aws-sdk-core/param_validator.rb +9 -4
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +6 -3
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -0
- data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +9 -3
- data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
- data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -1
- data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
- data/lib/aws-sdk-core/plugins/logging.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
- data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
- data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +3 -15
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
- data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +33 -3
- data/lib/aws-sdk-core/plugins/request_compression.rb +11 -2
- data/lib/aws-sdk-core/plugins/retry_errors.rb +12 -3
- data/lib/aws-sdk-core/plugins/sign.rb +27 -15
- data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
- data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
- data/lib/aws-sdk-core/plugins/stub_responses.rb +30 -2
- data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
- data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
- data/lib/aws-sdk-core/plugins/user_agent.rb +70 -26
- data/lib/aws-sdk-core/plugins.rb +39 -0
- data/lib/aws-sdk-core/process_credentials.rb +47 -28
- data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
- data/lib/aws-sdk-core/query/handler.rb +4 -4
- data/lib/aws-sdk-core/query/param_builder.rb +2 -2
- data/lib/aws-sdk-core/query.rb +2 -1
- data/lib/aws-sdk-core/refreshing_credentials.rb +12 -6
- data/lib/aws-sdk-core/resources.rb +8 -0
- data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
- data/lib/aws-sdk-core/rest/handler.rb +3 -4
- data/lib/aws-sdk-core/rest/request/body.rb +32 -5
- data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
- data/lib/aws-sdk-core/rest/request/headers.rb +15 -7
- data/lib/aws-sdk-core/rest/request/querystring_builder.rb +62 -36
- data/lib/aws-sdk-core/rest/response/body.rb +15 -1
- data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
- data/lib/aws-sdk-core/rest.rb +1 -0
- data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
- data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +45 -0
- data/lib/aws-sdk-core/rpc_v2/error_handler.rb +84 -0
- data/lib/aws-sdk-core/rpc_v2/handler.rb +78 -0
- data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
- data/lib/aws-sdk-core/rpc_v2.rb +6 -0
- data/lib/aws-sdk-core/shared_config.rb +7 -2
- data/lib/aws-sdk-core/shared_credentials.rb +0 -7
- data/lib/aws-sdk-core/sso_credentials.rb +2 -1
- data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +41 -0
- data/lib/aws-sdk-core/stubbing.rb +22 -0
- data/lib/aws-sdk-core/telemetry/base.rb +177 -0
- data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
- data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
- data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
- data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
- data/lib/aws-sdk-core/telemetry.rb +78 -0
- data/lib/aws-sdk-core/util.rb +39 -0
- data/lib/aws-sdk-core/waiters/poller.rb +10 -5
- data/lib/aws-sdk-core/xml/builder.rb +17 -9
- data/lib/aws-sdk-core/xml/error_handler.rb +32 -42
- data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core/xml/parser.rb +2 -6
- data/lib/aws-sdk-core.rb +82 -107
- data/lib/aws-sdk-sso/client.rb +119 -55
- data/lib/aws-sdk-sso/client_api.rb +7 -0
- data/lib/aws-sdk-sso/endpoint_provider.rb +30 -24
- data/lib/aws-sdk-sso/endpoints.rb +4 -16
- data/lib/aws-sdk-sso/plugins/endpoints.rb +22 -8
- data/lib/aws-sdk-sso/types.rb +1 -0
- data/lib/aws-sdk-sso.rb +15 -11
- data/lib/aws-sdk-ssooidc/client.rb +504 -83
- data/lib/aws-sdk-ssooidc/client_api.rb +83 -1
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +30 -24
- data/lib/aws-sdk-ssooidc/endpoints.rb +14 -12
- data/lib/aws-sdk-ssooidc/errors.rb +52 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +24 -8
- data/lib/aws-sdk-ssooidc/types.rb +373 -51
- data/lib/aws-sdk-ssooidc.rb +15 -11
- data/lib/aws-sdk-sts/client.rb +129 -57
- data/lib/aws-sdk-sts/client_api.rb +15 -11
- data/lib/aws-sdk-sts/customizations.rb +5 -1
- data/lib/aws-sdk-sts/endpoint_provider.rb +2 -2
- data/lib/aws-sdk-sts/endpoints.rb +8 -32
- data/lib/aws-sdk-sts/plugins/endpoints.rb +22 -8
- data/lib/aws-sdk-sts/presigner.rb +1 -1
- data/lib/aws-sdk-sts/types.rb +19 -4
- data/lib/aws-sdk-sts.rb +15 -11
- data/lib/seahorse/client/async_base.rb +1 -1
- data/lib/seahorse/client/async_response.rb +19 -0
- data/lib/seahorse/client/base.rb +18 -7
- data/lib/seahorse/client/h2/handler.rb +14 -3
- data/lib/seahorse/client/handler.rb +1 -1
- data/lib/seahorse/client/net_http/connection_pool.rb +11 -11
- data/lib/seahorse/client/net_http/handler.rb +21 -9
- data/lib/seahorse/client/net_http/patches.rb +1 -4
- data/lib/seahorse/client/plugin.rb +9 -0
- data/lib/seahorse/client/plugins/endpoint.rb +0 -1
- data/lib/seahorse/client/plugins/h2.rb +3 -3
- data/lib/seahorse/client/plugins/net_http.rb +57 -16
- data/lib/seahorse/client/request_context.rb +8 -1
- data/lib/seahorse/model/shapes.rb +2 -2
- data/sig/aws-sdk-core/client_stubs.rbs +10 -0
- data/sig/aws-sdk-core/errors.rbs +22 -0
- data/sig/aws-sdk-core/resources/collection.rbs +21 -0
- data/sig/aws-sdk-core/structure.rbs +4 -0
- data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
- data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
- data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
- data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
- data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
- data/sig/aws-sdk-core.rbs +7 -0
- data/sig/seahorse/client/base.rbs +25 -0
- data/sig/seahorse/client/handler_builder.rbs +16 -0
- data/sig/seahorse/client/response.rbs +61 -0
- metadata +59 -17
- /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
|
@@ -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
|
data/lib/aws-sdk-core/util.rb
CHANGED
|
@@ -67,6 +67,45 @@ module Aws
|
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
# @param [Number] input
|
|
71
|
+
# @return [Number, String] The serialized number
|
|
72
|
+
def serialize_number(input)
|
|
73
|
+
if input == ::Float::INFINITY then 'Infinity'
|
|
74
|
+
elsif input == -::Float::INFINITY then '-Infinity'
|
|
75
|
+
elsif input&.nan? then 'NaN'
|
|
76
|
+
else
|
|
77
|
+
input
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# @param [String] str
|
|
82
|
+
# @return [Number] The input as a number
|
|
83
|
+
def deserialize_number(str)
|
|
84
|
+
case str
|
|
85
|
+
when 'Infinity' then ::Float::INFINITY
|
|
86
|
+
when '-Infinity' then -::Float::INFINITY
|
|
87
|
+
when 'NaN' then ::Float::NAN
|
|
88
|
+
when nil then nil
|
|
89
|
+
else str.to_f
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# @param [String] value
|
|
94
|
+
# @return [Time]
|
|
95
|
+
def deserialize_time(value)
|
|
96
|
+
case value
|
|
97
|
+
when nil then nil
|
|
98
|
+
when /^[\d.]+$/ then Time.at(value.to_f).utc
|
|
99
|
+
else
|
|
100
|
+
begin
|
|
101
|
+
fractional_time = Time.parse(value).to_f
|
|
102
|
+
Time.at(fractional_time).utc
|
|
103
|
+
rescue ArgumentError
|
|
104
|
+
raise "unhandled timestamp format `#{value}'"
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
70
109
|
end
|
|
71
110
|
end
|
|
72
111
|
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
|
|
32
|
+
# @example A trivial (bad) example of a waiter that polls indefinetly.
|
|
33
33
|
#
|
|
34
34
|
# loop do
|
|
35
35
|
#
|
|
@@ -62,7 +62,7 @@ module Aws
|
|
|
62
62
|
def send_request(options)
|
|
63
63
|
req = options[:client].build_request(@operation_name, options[:params])
|
|
64
64
|
req.handlers.remove(RAISE_HANDLER)
|
|
65
|
-
Aws::Plugins::UserAgent.
|
|
65
|
+
Aws::Plugins::UserAgent.metric('WAITER') do
|
|
66
66
|
req.send_request
|
|
67
67
|
end
|
|
68
68
|
end
|
|
@@ -96,8 +96,13 @@ module Aws
|
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def matches_error?(acceptor, response)
|
|
99
|
-
|
|
100
|
-
|
|
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
|
|
115
|
+
values.is_a?(Array) && values.count > 0 ? yield(values) : false
|
|
111
116
|
else
|
|
112
117
|
false
|
|
113
118
|
end
|
|
@@ -10,6 +10,8 @@ module Aws
|
|
|
10
10
|
|
|
11
11
|
def initialize(rules, options = {})
|
|
12
12
|
@rules = rules
|
|
13
|
+
@location_name =
|
|
14
|
+
options[:location_name].nil? ? @rules.location_name : options[:location_name]
|
|
13
15
|
@xml = options[:target] || []
|
|
14
16
|
indent = options[:indent] || ''
|
|
15
17
|
pad = options[:pad] || ''
|
|
@@ -17,7 +19,7 @@ module Aws
|
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def to_xml(params)
|
|
20
|
-
structure(@
|
|
22
|
+
structure(@location_name, @rules, params)
|
|
21
23
|
@xml.join
|
|
22
24
|
end
|
|
23
25
|
alias serialize to_xml
|
|
@@ -50,7 +52,7 @@ module Aws
|
|
|
50
52
|
def list(name, ref, values)
|
|
51
53
|
if ref[:flattened] || ref.shape.flattened
|
|
52
54
|
values.each do |value|
|
|
53
|
-
member(
|
|
55
|
+
member(name, ref.shape.member, value)
|
|
54
56
|
end
|
|
55
57
|
else
|
|
56
58
|
node(name, ref) do
|
|
@@ -65,7 +67,7 @@ module Aws
|
|
|
65
67
|
def map(name, ref, hash)
|
|
66
68
|
key_ref = ref.shape.key
|
|
67
69
|
value_ref = ref.shape.value
|
|
68
|
-
if ref.shape.flattened
|
|
70
|
+
if ref[:flattened] || ref.shape.flattened
|
|
69
71
|
hash.each do |key, value|
|
|
70
72
|
node(name, ref) do
|
|
71
73
|
member(key_ref.location_name || 'key', key_ref, key)
|
|
@@ -75,7 +77,8 @@ module Aws
|
|
|
75
77
|
else
|
|
76
78
|
node(name, ref) do
|
|
77
79
|
hash.each do |key, value|
|
|
78
|
-
|
|
80
|
+
# Pass in a new ShapeRef to create an entry node
|
|
81
|
+
node('entry', ShapeRef.new) do
|
|
79
82
|
member(key_ref.location_name || 'key', key_ref, key)
|
|
80
83
|
member(value_ref.location_name || 'value', value_ref, value)
|
|
81
84
|
end
|
|
@@ -129,11 +132,16 @@ module Aws
|
|
|
129
132
|
end
|
|
130
133
|
|
|
131
134
|
def shape_attrs(ref)
|
|
132
|
-
if xmlns = ref['xmlNamespace']
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
if (xmlns = ref['xmlNamespace'])
|
|
136
|
+
case xmlns
|
|
137
|
+
when String
|
|
138
|
+
{ 'xmlns' => xmlns }
|
|
139
|
+
when Hash
|
|
140
|
+
if (prefix = xmlns['prefix'])
|
|
141
|
+
{ "xmlns:#{prefix}" => xmlns['uri'] }
|
|
142
|
+
else
|
|
143
|
+
{ 'xmlns' => xmlns['uri'] }
|
|
144
|
+
end
|
|
137
145
|
end
|
|
138
146
|
else
|
|
139
147
|
{}
|
|
@@ -4,7 +4,7 @@ require 'cgi'
|
|
|
4
4
|
|
|
5
5
|
module Aws
|
|
6
6
|
module Xml
|
|
7
|
-
class ErrorHandler <
|
|
7
|
+
class ErrorHandler < Aws::ErrorHandler
|
|
8
8
|
|
|
9
9
|
def call(context)
|
|
10
10
|
@handler.call(context).on(300..599) do |response|
|
|
@@ -15,42 +15,29 @@ 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
|
-
error_class = errors_module.error_class(code).new(context, message, data)
|
|
30
|
-
error_class
|
|
31
|
-
end
|
|
32
|
-
|
|
33
18
|
def extract_error(body, context)
|
|
19
|
+
context[:request_id] = request_id(body)
|
|
34
20
|
code = error_code(body, context)
|
|
35
21
|
[
|
|
36
22
|
code,
|
|
37
23
|
error_message(body),
|
|
38
|
-
error_data(context, code)
|
|
24
|
+
error_data(context, body, code)
|
|
39
25
|
]
|
|
40
26
|
end
|
|
41
27
|
|
|
42
|
-
def error_data(context, code)
|
|
28
|
+
def error_data(context, body, code)
|
|
43
29
|
data = EmptyStructure.new
|
|
44
|
-
if error_rules = context.operation.errors
|
|
30
|
+
if (error_rules = context.operation.errors)
|
|
45
31
|
error_rules.each do |rule|
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
# match modeled shape name
|
|
32
|
+
# query protocol may have custom error code
|
|
33
|
+
# reference: https://smithy.io/2.0/aws/protocols/aws-query-protocol.html#error-code-resolution
|
|
49
34
|
error_shape_code = rule.shape['error']['code'] if rule.shape['error']
|
|
50
35
|
match = (code == error_shape_code || code == rule.shape.name)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
next unless match && rule.shape.members.any?
|
|
37
|
+
|
|
38
|
+
data = parse_error_data(rule, body)
|
|
39
|
+
# supporting HTTP bindings
|
|
40
|
+
apply_error_headers(rule, context, data)
|
|
54
41
|
end
|
|
55
42
|
end
|
|
56
43
|
data
|
|
@@ -58,29 +45,32 @@ module Aws
|
|
|
58
45
|
EmptyStructure.new
|
|
59
46
|
end
|
|
60
47
|
|
|
48
|
+
def parse_error_data(rule, body)
|
|
49
|
+
# errors may nested under <Errors><Error>structure_data</Error></Errors>
|
|
50
|
+
# Or may be flat and under <Error>structure_data</Error>
|
|
51
|
+
body = body.tr("\n", '')
|
|
52
|
+
if (matches = body.match(/<Error>(.+?)<\/Error>/))
|
|
53
|
+
Parser.new(rule).parse("<#{rule.shape.name}>#{matches[1]}</#{rule.shape.name}>")
|
|
54
|
+
else
|
|
55
|
+
EmptyStructure.new
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def apply_error_headers(rule, context, data)
|
|
60
|
+
headers = Aws::Rest::Response::Headers.new(rule)
|
|
61
|
+
headers.apply(context.http_response, data)
|
|
62
|
+
end
|
|
63
|
+
|
|
61
64
|
def error_code(body, context)
|
|
62
|
-
if matches = body.match(/<Code>(.+?)<\/Code>/)
|
|
65
|
+
if (matches = body.match(/<Code>(.+?)<\/Code>/))
|
|
63
66
|
remove_prefix(unescape(matches[1]), context)
|
|
64
67
|
else
|
|
65
68
|
http_status_error_code(context)
|
|
66
69
|
end
|
|
67
70
|
end
|
|
68
71
|
|
|
69
|
-
def http_status_error_code(context)
|
|
70
|
-
status_code = context.http_response.status_code
|
|
71
|
-
{
|
|
72
|
-
302 => 'MovedTemporarily',
|
|
73
|
-
304 => 'NotModified',
|
|
74
|
-
400 => 'BadRequest',
|
|
75
|
-
403 => 'Forbidden',
|
|
76
|
-
404 => 'NotFound',
|
|
77
|
-
412 => 'PreconditionFailed',
|
|
78
|
-
413 => 'RequestEntityTooLarge',
|
|
79
|
-
}[status_code] || "Http#{status_code}Error"
|
|
80
|
-
end
|
|
81
|
-
|
|
82
72
|
def remove_prefix(error_code, context)
|
|
83
|
-
if prefix = context.config.api.metadata['errorPrefix']
|
|
73
|
+
if (prefix = context.config.api.metadata['errorPrefix'])
|
|
84
74
|
error_code.sub(/^#{prefix}/, '')
|
|
85
75
|
else
|
|
86
76
|
error_code
|
|
@@ -88,7 +78,7 @@ module Aws
|
|
|
88
78
|
end
|
|
89
79
|
|
|
90
80
|
def error_message(body)
|
|
91
|
-
if matches = body.match(/<Message>(.+?)<\/Message>/m)
|
|
81
|
+
if (matches = body.match(/<Message>(.+?)<\/Message>/m))
|
|
92
82
|
unescape(matches[1])
|
|
93
83
|
else
|
|
94
84
|
''
|
|
@@ -96,7 +86,7 @@ module Aws
|
|
|
96
86
|
end
|
|
97
87
|
|
|
98
88
|
def request_id(body)
|
|
99
|
-
if matches = body.match(/<RequestId>(.+?)<\/RequestId>/m)
|
|
89
|
+
if (matches = body.match(/<RequestId>(.+?)<\/RequestId>/m))
|
|
100
90
|
matches[1]
|
|
101
91
|
end
|
|
102
92
|
end
|