aws-sdk-core 3.202.2 → 3.206.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-core/endpoints.rb +6 -3
  5. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +1 -0
  6. data/lib/aws-sdk-core/plugins/stub_responses.rb +29 -2
  7. data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
  8. data/lib/aws-sdk-core/plugins/user_agent.rb +12 -8
  9. data/lib/aws-sdk-core/rpc_v2/handler.rb +5 -1
  10. data/lib/aws-sdk-core/telemetry/base.rb +177 -0
  11. data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
  12. data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
  13. data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
  14. data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
  15. data/lib/aws-sdk-core/telemetry.rb +78 -0
  16. data/lib/aws-sdk-core.rb +2 -12
  17. data/lib/aws-sdk-sso/client.rb +25 -2
  18. data/lib/aws-sdk-sso/endpoints.rb +4 -16
  19. data/lib/aws-sdk-sso/plugins/endpoints.rb +10 -1
  20. data/lib/aws-sdk-sso.rb +1 -1
  21. data/lib/aws-sdk-ssooidc/client.rb +25 -2
  22. data/lib/aws-sdk-ssooidc/endpoints.rb +4 -16
  23. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +10 -1
  24. data/lib/aws-sdk-ssooidc.rb +1 -1
  25. data/lib/aws-sdk-sts/client.rb +25 -2
  26. data/lib/aws-sdk-sts/endpoints.rb +8 -32
  27. data/lib/aws-sdk-sts/plugins/endpoints.rb +10 -1
  28. data/lib/aws-sdk-sts.rb +1 -1
  29. data/lib/seahorse/client/h2/handler.rb +13 -3
  30. data/lib/seahorse/client/net_http/connection_pool.rb +8 -2
  31. data/lib/seahorse/client/net_http/handler.rb +18 -1
  32. data/lib/seahorse/client/plugins/net_http.rb +9 -0
  33. data/lib/seahorse/client/request_context.rb +8 -1
  34. data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
  35. data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
  36. data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
  37. data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
  38. metadata +13 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0072b215b84fdf20732969f2e6c471ba8b5b9a27de261addc0518fe650d31eec
4
- data.tar.gz: 01e7506da1222047c1e852fa375b84f104a16476057de6448ad79582d5096345
3
+ metadata.gz: a367793c192d43de9b14d55b9de1c3d888fcb850b06ab3a257eef6e49e368ee0
4
+ data.tar.gz: 499e081e6fcb025dcc851ca385c487bcabe38db7f5f71c1f58b7fd8e1a8a0c73
5
5
  SHA512:
6
- metadata.gz: 4306a917a294c832eb03c3c26257b11d5e20a50224808ade0d71e3856f27c02c0e2e0ea0b9aab2c97718035938de0fd058b2abefb96dae00f07c2d3b1a44eb3c
7
- data.tar.gz: 7fed48d60a2e1ae6dcf968af4c4291153417ef22b0b3e8aa69fae68d3b89b88ad43fb5f2d2a453295eb28b45376cb2602bfd3d688d8d7bbde3aa12b5c5e038d5
6
+ metadata.gz: bcf36ccf81b3452e352a4464962df3d6a7511bee43f2bd16724c2ed9787a79710ae3afb4311be23b069428085f9bbaae3674a63a37f8d55f50c5ab6170536b99
7
+ data.tar.gz: 4fa01e283a5c31d2d77d01d7037450d34130cd7a997bf05fe1b33bd88c7bd699d706ad76c02791321457e011e5bb23c5859b571ad05a3beb4c02be4fae08ebbf
data/CHANGELOG.md CHANGED
@@ -1,6 +1,44 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.206.0 (2024-09-17)
5
+ ------------------
6
+
7
+ * Feature - Support `sigv4a` endpoint auth without CRT.
8
+
9
+ 3.205.0 (2024-09-11)
10
+ ------------------
11
+
12
+ * Feature - Updated Aws::STS::Client with the latest API changes.
13
+
14
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
15
+
16
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
17
+
18
+ * Issue - Additional metrics collection in the User-Agent plugin.
19
+
20
+ 3.204.0 (2024-09-10)
21
+ ------------------
22
+
23
+ * Feature - Updated Aws::STS::Client with the latest API changes.
24
+
25
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
26
+
27
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
28
+
29
+ * Issue - Add support for `ssl_cert` and `ssl_key` configuration options to support mTLS.
30
+
31
+ 3.203.0 (2024-09-03)
32
+ ------------------
33
+
34
+ * Feature - Updated Aws::STS::Client with the latest API changes.
35
+
36
+ * Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
37
+
38
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
39
+
40
+ * Feature - Add support for Observability which includes a configuration, `telemetry_provider` and an OpenTelemetry-based telemetry provider.
41
+
4
42
  3.202.2 (2024-08-30)
5
43
  ------------------
6
44
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.202.2
1
+ 3.206.0
@@ -19,9 +19,12 @@ require 'aws-sigv4'
19
19
  module Aws
20
20
  # @api private
21
21
  module Endpoints
22
- supported_auth_traits = %w[aws.auth#sigv4 smithy.api#httpBearerAuth smithy.api#noAuth]
23
- supported_auth_traits += ['aws.auth#sigv4a'] if Aws::Sigv4::Signer.use_crt?
24
- SUPPORTED_AUTH_TRAITS = supported_auth_traits.freeze
22
+ SUPPORTED_AUTH_TRAITS = %w[
23
+ aws.auth#sigv4
24
+ aws.auth#sigv4a
25
+ smithy.api#httpBearerAuth
26
+ smithy.api#noAuth
27
+ ].freeze
25
28
 
26
29
  class << self
27
30
  def resolve_auth_scheme(context, endpoint)
@@ -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