aws-sdk-core 3.201.5 → 3.205.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +54 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +1 -0
  5. data/lib/aws-sdk-core/plugins/stub_responses.rb +29 -2
  6. data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
  7. data/lib/aws-sdk-core/plugins/user_agent.rb +12 -8
  8. data/lib/aws-sdk-core/rpc_v2/handler.rb +5 -1
  9. data/lib/aws-sdk-core/telemetry/base.rb +177 -0
  10. data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
  11. data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
  12. data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
  13. data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
  14. data/lib/aws-sdk-core/telemetry.rb +78 -0
  15. data/lib/aws-sdk-core.rb +2 -12
  16. data/lib/aws-sdk-sso/client.rb +25 -2
  17. data/lib/aws-sdk-sso/endpoints.rb +4 -16
  18. data/lib/aws-sdk-sso/plugins/endpoints.rb +10 -1
  19. data/lib/aws-sdk-sso.rb +1 -1
  20. data/lib/aws-sdk-ssooidc/client.rb +25 -2
  21. data/lib/aws-sdk-ssooidc/endpoints.rb +4 -16
  22. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +10 -1
  23. data/lib/aws-sdk-ssooidc.rb +1 -1
  24. data/lib/aws-sdk-sts/client.rb +25 -2
  25. data/lib/aws-sdk-sts/endpoints.rb +8 -32
  26. data/lib/aws-sdk-sts/plugins/endpoints.rb +10 -1
  27. data/lib/aws-sdk-sts.rb +1 -1
  28. data/lib/seahorse/client/h2/handler.rb +13 -3
  29. data/lib/seahorse/client/net_http/connection_pool.rb +8 -2
  30. data/lib/seahorse/client/net_http/handler.rb +18 -1
  31. data/lib/seahorse/client/plugins/net_http.rb +9 -0
  32. data/lib/seahorse/client/request_context.rb +8 -1
  33. data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
  34. data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
  35. data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
  36. data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
  37. metadata +13 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c56ef3ae86efb90f1b4aa05e586125837d299507a328f91da2e3ee8cb21a526
4
- data.tar.gz: 320c4f2b04bfee3a2dc133c9efe918ca386c36037339d0a734e8fdf8ed8e419f
3
+ metadata.gz: 2d3b4f9e7c9f140f0b216c6906c6b23135826ca87fdc8fc8a1a427b5b655f8f0
4
+ data.tar.gz: 47e453550bd7e0131a1b0f8f1a3d08b442546cca675c43685c9bac6550d1cc45
5
5
  SHA512:
6
- metadata.gz: 88d9eafad3840eb07638dc6aa556611056554f493b56c6027d3afbd2b181cc7ea9ab7e8beaf3f9f30eb7adc13257524a00cc59c6ec8ae91e966fe92162404151
7
- data.tar.gz: b4732037f71e7b0bd2b536a6f39a6bba83939d274c3e4231b37aa15afdb12b3a736d89422eed917c26972c038e5ac4c7f23d591ba6498d80151cdf764f47e8ce
6
+ metadata.gz: 0a1138a6ef760e057c942ea81263c6db0af07b267715bd6467bdfaabed5ec01c45dc4b4297c4db397ae2dca534c6af55e4aec8b9c158b395d99a22c0b50fe205
7
+ data.tar.gz: 5366ddf0b85dd20f0a177a7b5c44ebc3d6d2eabc898f6d5934a75795bee36dc1e5c4eb677781ba77e39807c2cea412deff17ba732e038810bc2e640f963157e8
data/CHANGELOG.md CHANGED
@@ -1,6 +1,60 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.205.0 (2024-09-11)
5
+ ------------------
6
+
7
+ * Feature - Updated Aws::STS::Client with the latest API changes.
8
+
9
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
10
+
11
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
12
+
13
+ * Issue - Additional metrics collection in the User-Agent plugin.
14
+
15
+ 3.204.0 (2024-09-10)
16
+ ------------------
17
+
18
+ * Feature - Updated Aws::STS::Client with the latest API changes.
19
+
20
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
21
+
22
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
23
+
24
+ * Issue - Add support for `ssl_cert` and `ssl_key` configuration options to support mTLS.
25
+
26
+ 3.203.0 (2024-09-03)
27
+ ------------------
28
+
29
+ * Feature - Updated Aws::STS::Client with the latest API changes.
30
+
31
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
32
+
33
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
34
+
35
+ * Feature - Add support for Observability which includes a configuration, `telemetry_provider` and an OpenTelemetry-based telemetry provider.
36
+
37
+ 3.202.2 (2024-08-30)
38
+ ------------------
39
+
40
+ * Issue - revert auto-loading of bundled gems.
41
+
42
+ 3.202.1 (2024-08-29)
43
+ ------------------
44
+
45
+ * Issue - require default plugins when loading aws-sdk-core.
46
+
47
+ 3.202.0 (2024-08-27)
48
+ ------------------
49
+
50
+ * Feature - Updated Aws::STS::Client with the latest API changes.
51
+
52
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
53
+
54
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
55
+
56
+ * Issue - Reduce initial memory usage by auto-loading bundled gems (STS, SSO, SSOOIDC).
57
+
4
58
  3.201.5 (2024-08-15)
5
59
  ------------------
6
60
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.201.5
1
+ 3.205.0
@@ -205,6 +205,7 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
205
205
  cfg.override_config(:region, new_region)
206
206
  end
207
207
  end
208
+
208
209
  # set a default endpoint in config using legacy (endpoints.json) resolver
209
210
  def resolve_legacy_endpoint(cfg)
210
211
  endpoint_prefix = cfg.api.metadata['endpointPrefix']
@@ -49,6 +49,14 @@ requests are made, and retries are disabled.
49
49
  class Handler < Seahorse::Client::Handler
50
50
 
51
51
  def call(context)
52
+ span_wrapper(context) do
53
+ stub_responses(context)
54
+ end
55
+ end
56
+
57
+ private
58
+
59
+ def stub_responses(context)
52
60
  stub = context.client.next_stub(context)
53
61
  resp = Seahorse::Client::Response.new(context: context)
54
62
  async_mode = context.client.is_a? Seahorse::Client::AsyncBase
@@ -58,8 +66,15 @@ requests are made, and retries are disabled.
58
66
  apply_stub(stub, resp, async_mode)
59
67
  end
60
68
 
61
- async_mode ? Seahorse::Client::AsyncResponse.new(
62
- context: context, stream: context[:input_event_stream_handler].event_emitter.stream, sync_queue: Queue.new) : resp
69
+ if async_mode
70
+ Seahorse::Client::AsyncResponse.new(
71
+ context: context,
72
+ stream: context[:input_event_stream_handler].event_emitter.stream,
73
+ sync_queue: Queue.new
74
+ )
75
+ else
76
+ resp
77
+ end
63
78
  end
64
79
 
65
80
  def apply_stub(stub, response, async_mode = false)
@@ -99,6 +114,18 @@ requests are made, and retries are disabled.
99
114
  http_resp.signal_done
100
115
  end
101
116
 
117
+ def span_wrapper(context, &block)
118
+ context.tracer.in_span(
119
+ 'Handler.StubResponses',
120
+ attributes: Aws::Telemetry.http_request_attrs(context)
121
+ ) do |span|
122
+ block.call.tap do
123
+ span.add_attributes(
124
+ Aws::Telemetry.http_response_attrs(context)
125
+ )
126
+ end
127
+ end
128
+ end
102
129
  end
103
130
  end
104
131
  end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Plugins
5
+ # @api private
6
+ class Telemetry < Seahorse::Client::Plugin
7
+ option(
8
+ :telemetry_provider,
9
+ default: Aws::Telemetry::NoOpTelemetryProvider,
10
+ doc_type: Aws::Telemetry::TelemetryProviderBase,
11
+ rbs_type: Aws::Telemetry::TelemetryProviderBase,
12
+ docstring: <<-DOCS) do |_cfg|
13
+ Allows you to provide a telemetry provider, which is used to
14
+ emit telemetry data. By default, uses `NoOpTelemetryProvider` which
15
+ will not record or emit any telemetry data. The SDK supports the
16
+ following telemetry providers:
17
+
18
+ * OpenTelemetry (OTel) - To use the OTel provider, install and require the
19
+ `opentelemetry-sdk` gem and then, pass in an instance of a
20
+ `Aws::Telemetry::OTelProvider` for telemetry provider.
21
+ DOCS
22
+ Aws::Telemetry::NoOpTelemetryProvider.new
23
+ end
24
+
25
+ def after_initialize(client)
26
+ validate_telemetry_provider(client.config)
27
+ end
28
+
29
+ def validate_telemetry_provider(config)
30
+ unless config.telemetry_provider.is_a?(Aws::Telemetry::TelemetryProviderBase)
31
+ raise ArgumentError,
32
+ 'Must provide a telemetry provider for the '\
33
+ '`telemetry_provider` configuration option.'
34
+ end
35
+ end
36
+
37
+ class Handler < Seahorse::Client::Handler
38
+ def call(context)
39
+ span_wrapper(context) { @handler.call(context) }
40
+ end
41
+
42
+ private
43
+
44
+ def span_wrapper(context, &block)
45
+ service_id = service_id(context)
46
+ attributes = {
47
+ 'rpc.system' => 'aws-api',
48
+ 'rpc.service' => service_id,
49
+ 'rpc.method' => context.operation.name,
50
+ 'code.function' => context.operation_name.to_s,
51
+ 'code.namespace' => 'Aws::Plugins::Telemetry'
52
+ }
53
+ context.tracer.in_span(
54
+ parent_span_name(context, service_id),
55
+ attributes: attributes,
56
+ kind: Aws::Telemetry::SpanKind::CLIENT,
57
+ &block
58
+ )
59
+ end
60
+
61
+ def service_id(context)
62
+ context.config.api.metadata['serviceId'] ||
63
+ context.config.api.metadata['serviceAbbreviation'] ||
64
+ context.config.api.metadata['serviceFullName']
65
+ end
66
+
67
+ def parent_span_name(context, service_id)
68
+ "#{service_id}.#{context.operation.name}".delete(' ')
69
+ end
70
+ end
71
+
72
+ handler(Handler, step: :initialize, priority: 99)
73
+ end
74
+ end
75
+ end
@@ -17,7 +17,10 @@ module Aws
17
17
  "S3_CRYPTO_V2": "I",
18
18
  "S3_EXPRESS_BUCKET": "J",
19
19
  "S3_ACCESS_GRANTS": "K",
20
- "GZIP_REQUEST_COMPRESSION": "L"
20
+ "GZIP_REQUEST_COMPRESSION": "L",
21
+ "PROTOCOL_RPC_V2_CBOR": "M",
22
+ "ENDPOINT_OVERRIDE": "N",
23
+ "SIGV4A_SIGNING": "S"
21
24
  }
22
25
  METRICS
23
26
 
@@ -45,15 +48,13 @@ variable AWS_SDK_UA_APP_ID or the shared config profile attribute sdk_ua_app_id.
45
48
  block.call
46
49
  end
47
50
 
48
- def self.metric(metric, &block)
51
+ def self.metric(*metrics, &block)
49
52
  Thread.current[:aws_sdk_core_user_agent_metric] ||= []
50
- Thread.current[:aws_sdk_core_user_agent_metric] << METRICS[metric]
53
+ metrics = metrics.map { |metric| METRICS[metric] }.compact
54
+ Thread.current[:aws_sdk_core_user_agent_metric].concat(metrics)
51
55
  block.call
52
56
  ensure
53
- Thread.current[:aws_sdk_core_user_agent_metric].pop
54
- if Thread.current[:aws_sdk_core_user_agent_metric].empty?
55
- Thread.current[:aws_sdk_core_user_agent_metric] = nil
56
- end
57
+ Thread.current[:aws_sdk_core_user_agent_metric].pop(metrics.size)
57
58
  end
58
59
 
59
60
  # @api private
@@ -166,7 +167,10 @@ variable AWS_SDK_UA_APP_ID or the shared config profile attribute sdk_ua_app_id.
166
167
  end
167
168
 
168
169
  def metric_metadata
169
- return unless Thread.current[:aws_sdk_core_user_agent_metric]
170
+ if Thread.current[:aws_sdk_core_user_agent_metric].nil? ||
171
+ Thread.current[:aws_sdk_core_user_agent_metric].empty?
172
+ return
173
+ end
170
174
 
171
175
  metrics = Thread.current[:aws_sdk_core_user_agent_metric].join(',')
172
176
  # Metric metadata is limited to 1024 bytes
@@ -7,7 +7,7 @@ module Aws
7
7
  # @return [Seahorse::Client::Response]
8
8
  def call(context)
9
9
  build_request(context)
10
- response = @handler.call(context)
10
+ response = with_metric { @handler.call(context) }
11
11
  response.on(200..299) { |resp| resp.data = parse_body(context) }
12
12
  response.on(200..599) { |_resp| apply_request_id(context) }
13
13
  response
@@ -15,6 +15,10 @@ module Aws
15
15
 
16
16
  private
17
17
 
18
+ def with_metric(&block)
19
+ Aws::Plugins::UserAgent.metric('PROTOCOL_RPC_V2_CBOR', &block)
20
+ end
21
+
18
22
  def build_request(context)
19
23
  context.http_request.headers['smithy-protocol'] = 'rpc-v2-cbor'
20
24
  context.http_request.http_method = 'POST'
@@ -0,0 +1,177 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Telemetry
5
+ # Base for `TelemetryProvider` classes.
6
+ # They are used to emit telemetry data. It needs the
7
+ # following class implementations to function:
8
+ # * {TracerProviderBase} - A provider that returns a tracer
9
+ # instance. Then, a tracer will create spans and those
10
+ # spans will contain information in that given moment.
11
+ # * {ContextManagerBase} - Manages context and used to
12
+ # return the current context within a trace.
13
+ class TelemetryProviderBase
14
+ # @param [Aws::Telemetry::TracerBase] tracer_provider A provider
15
+ # that returns a tracer instance.
16
+ # @param [Aws::Telemetry::ContextManagerBase] context_manager Manages
17
+ # context and used to return the current context.
18
+ def initialize(tracer_provider: nil, context_manager: nil)
19
+ @tracer_provider = tracer_provider
20
+ @context_manager = context_manager
21
+ end
22
+
23
+ # @return [Aws::Telemetry::TracerProviderBase]
24
+ attr_reader :tracer_provider
25
+
26
+ # @return [Aws::Telemetry::ContextManagerBase]
27
+ attr_reader :context_manager
28
+ end
29
+
30
+ # Base for `TracerProvider` classes.
31
+ class TracerProviderBase
32
+ # Returns a Tracer instance.
33
+ #
34
+ # @param [String] name Tracer name
35
+ # @return [Aws::Telemetry::TracerBase]
36
+ def tracer(name = nil)
37
+ raise NotImplementedError
38
+ end
39
+ end
40
+
41
+ # Base for `Tracer` classes.
42
+ class TracerBase
43
+ # Used when a caller wants to manage the activation/deactivation and
44
+ # lifecycle of the Span and its parent manually.
45
+ #
46
+ # @param [String] name Span name
47
+ # @param [Object] with_parent Parent Context
48
+ # @param [Hash] attributes Attributes to attach to the span
49
+ # @param [Aws::Telemetry::SpanKind] kind Type of Span
50
+ # @return [Aws::Telemetry::SpanBase]
51
+ def start_span(name, with_parent: nil, attributes: nil, kind: nil)
52
+ raise NotImplementedError
53
+ end
54
+
55
+ # A helper for the default use-case of extending the current trace
56
+ # with a span.
57
+ # On exit, the Span that was active before calling this method will
58
+ # be reactivated. If an exception occurs during the execution of the
59
+ # provided block, it will be recorded on the span and re-raised.
60
+ #
61
+ # @param [String] name Span name
62
+ # @param [Hash] attributes Attributes to attach to the span
63
+ # @param [Aws::Telemetry::SpanKind] kind Type of Span
64
+ # @return [Aws::Telemetry::SpanBase]
65
+ def in_span(name, attributes: nil, kind: nil)
66
+ raise NotImplementedError
67
+ end
68
+
69
+ # Returns the current active span.
70
+ #
71
+ # @return [Aws::Telemetry::SpanBase]
72
+ def current_span
73
+ raise NotImplementedError
74
+ end
75
+ end
76
+
77
+ # Base for `Span` classes.
78
+ class SpanBase
79
+ # Set attribute.
80
+ #
81
+ # @param [String] key
82
+ # @param [String, Boolean, Numeric, Array<String, Numeric, Boolean>] value
83
+ # Value must be non-nil and (array of) string, boolean or numeric type.
84
+ # Array values must not contain nil elements and all elements must be of
85
+ # the same basic type (string, numeric, boolean)
86
+ # @return [self] returns itself
87
+ def set_attribute(key, value)
88
+ raise NotImplementedError
89
+ end
90
+ alias []= set_attribute
91
+
92
+ # Add attributes.
93
+ #
94
+ # @param [Hash{String => String, Numeric, Boolean, Array<String, Numeric,
95
+ # Boolean>}] attributes Values must be non-nil and (array of) string,
96
+ # boolean or numeric type. Array values must not contain nil elements
97
+ # and all elements must be of the same basic type (string, numeric,
98
+ # boolean)
99
+ # @return [self] returns itself
100
+ def add_attributes(attributes)
101
+ raise NotImplementedError
102
+ end
103
+
104
+ # Add event to a Span.
105
+ #
106
+ # @param [String] name Name of the event
107
+ # @param [Hash{String => String, Numeric, Boolean, Array<String,
108
+ # Numeric, Boolean>}] attributes Values must be non-nil and (array of)
109
+ # string, boolean or numeric type. Array values must not contain nil
110
+ # elements and all elements must be of the same basic type (string,
111
+ # numeric, boolean)
112
+ # @return [self] returns itself
113
+ def add_event(name, attributes: nil)
114
+ raise NotImplementedError
115
+ end
116
+
117
+ # Sets the Span status.
118
+ #
119
+ # @param [Aws::Telemetry::SpanStatus] status The new status, which
120
+ # overrides the default Span status, which is `OK`
121
+ # @return [void]
122
+ def status=(status)
123
+ raise NotImplementedError
124
+ end
125
+
126
+ # Finishes the Span.
127
+ #
128
+ # @param [Time] end_timestamp End timestamp for the span.
129
+ # @return [self] returns itself
130
+ def finish(end_timestamp: nil)
131
+ raise NotImplementedError
132
+ end
133
+
134
+ # Record an exception during the execution of this span. Multiple
135
+ # exceptions can be recorded on a span.
136
+ #
137
+ # @param [Exception] exception The exception to be recorded
138
+ # @param [Hash{String => String, Numeric, Boolean, Array<String,
139
+ # Numeric, Boolean>}] attributes One or more key:value pairs, where the
140
+ # keys must be strings and the values may be (array of) string, boolean
141
+ # or numeric type.
142
+ # @return [void]
143
+ def record_exception(exception, attributes: nil)
144
+ raise NotImplementedError
145
+ end
146
+ end
147
+
148
+ # Base for all `ContextManager` classes.
149
+ class ContextManagerBase
150
+ # Returns current context.
151
+ #
152
+ # @return [Context]
153
+ def current
154
+ raise NotImplementedError
155
+ end
156
+
157
+ # Associates a Context with the caller’s current execution unit.
158
+ # Returns a token to be used with the matching call to detach.
159
+ #
160
+ # @param [Object] context The new context
161
+ # @return [Object] token A token to be used when detaching
162
+ def attach(context)
163
+ raise NotImplementedError
164
+ end
165
+
166
+ # Restore the previous Context associated with the current
167
+ # execution unit to the value it had before attaching a
168
+ # specified Context.
169
+ #
170
+ # @param [Object] token The token provided by matching the call to attach
171
+ # @return [Boolean] `True` if the calls matched, `False` otherwise
172
+ def detach(token)
173
+ raise NotImplementedError
174
+ end
175
+ end
176
+ end
177
+ end
@@ -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