aws-sdk-core 3.201.3 → 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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +113 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults.rb +4 -1
  5. data/lib/aws-sdk-core/assume_role_credentials.rb +12 -5
  6. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +13 -7
  7. data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
  8. data/lib/aws-sdk-core/credential_provider_chain.rb +9 -2
  9. data/lib/aws-sdk-core/credentials.rb +13 -6
  10. data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
  11. data/lib/aws-sdk-core/endpoints.rb +6 -3
  12. data/lib/aws-sdk-core/log.rb +10 -0
  13. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +7 -3
  14. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +1 -0
  15. data/lib/aws-sdk-core/plugins/sign.rb +2 -3
  16. data/lib/aws-sdk-core/plugins/stub_responses.rb +29 -2
  17. data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
  18. data/lib/aws-sdk-core/plugins/user_agent.rb +17 -8
  19. data/lib/aws-sdk-core/plugins.rb +39 -0
  20. data/lib/aws-sdk-core/process_credentials.rb +2 -1
  21. data/lib/aws-sdk-core/resources.rb +8 -0
  22. data/lib/aws-sdk-core/rpc_v2/handler.rb +5 -1
  23. data/lib/aws-sdk-core/shared_config.rb +3 -1
  24. data/lib/aws-sdk-core/shared_credentials.rb +0 -7
  25. data/lib/aws-sdk-core/sso_credentials.rb +2 -1
  26. data/lib/aws-sdk-core/stubbing.rb +22 -0
  27. data/lib/aws-sdk-core/telemetry/base.rb +177 -0
  28. data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
  29. data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
  30. data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
  31. data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
  32. data/lib/aws-sdk-core/telemetry.rb +78 -0
  33. data/lib/aws-sdk-core/waiters/poller.rb +9 -4
  34. data/lib/aws-sdk-core.rb +82 -112
  35. data/lib/aws-sdk-sso/client.rb +35 -8
  36. data/lib/aws-sdk-sso/client_api.rb +1 -0
  37. data/lib/aws-sdk-sso/endpoints.rb +4 -16
  38. data/lib/aws-sdk-sso/plugins/endpoints.rb +18 -6
  39. data/lib/aws-sdk-sso/types.rb +1 -0
  40. data/lib/aws-sdk-sso.rb +15 -11
  41. data/lib/aws-sdk-ssooidc/client.rb +35 -8
  42. data/lib/aws-sdk-ssooidc/client_api.rb +1 -0
  43. data/lib/aws-sdk-ssooidc/endpoints.rb +4 -16
  44. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +18 -6
  45. data/lib/aws-sdk-ssooidc/types.rb +1 -0
  46. data/lib/aws-sdk-ssooidc.rb +15 -11
  47. data/lib/aws-sdk-sts/client.rb +35 -8
  48. data/lib/aws-sdk-sts/client_api.rb +1 -0
  49. data/lib/aws-sdk-sts/customizations.rb +5 -1
  50. data/lib/aws-sdk-sts/endpoints.rb +8 -32
  51. data/lib/aws-sdk-sts/plugins/endpoints.rb +18 -6
  52. data/lib/aws-sdk-sts/types.rb +1 -0
  53. data/lib/aws-sdk-sts.rb +15 -11
  54. data/lib/seahorse/client/h2/handler.rb +13 -3
  55. data/lib/seahorse/client/net_http/connection_pool.rb +8 -2
  56. data/lib/seahorse/client/net_http/handler.rb +21 -9
  57. data/lib/seahorse/client/plugins/net_http.rb +9 -0
  58. data/lib/seahorse/client/request_context.rb +8 -1
  59. data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
  60. data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
  61. data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
  62. data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
  63. metadata +20 -4
@@ -198,6 +198,7 @@ module Aws
198
198
 
199
199
  config_reader(
200
200
  :region,
201
+ :account_id_endpoint_mode,
201
202
  :sigv4a_signing_region_set,
202
203
  :ca_bundle,
203
204
  :credential_process,
@@ -414,7 +415,8 @@ module Aws
414
415
  creds = Credentials.new(
415
416
  prof_config['aws_access_key_id'],
416
417
  prof_config['aws_secret_access_key'],
417
- prof_config['aws_session_token']
418
+ prof_config['aws_session_token'],
419
+ account_id: prof_config['aws_account_id']
418
420
  )
419
421
  creds if creds.set?
420
422
  end
@@ -7,13 +7,6 @@ module Aws
7
7
 
8
8
  include CredentialProvider
9
9
 
10
- # @api private
11
- KEY_MAP = {
12
- 'aws_access_key_id' => 'access_key_id',
13
- 'aws_secret_access_key' => 'secret_access_key',
14
- 'aws_session_token' => 'session_token',
15
- }
16
-
17
10
  # Constructs a new SharedCredentials object. This will load static
18
11
  # (access_key_id, secret_access_key and session_token) AWS access
19
12
  # credentials from an ini file, which supports profiles. The default
@@ -156,7 +156,8 @@ module Aws
156
156
  @credentials = Credentials.new(
157
157
  c.access_key_id,
158
158
  c.secret_access_key,
159
- c.session_token
159
+ c.session_token,
160
+ account_id: @sso_account_id
160
161
  )
161
162
  @expiration = Time.at(c.expiration / 1000.0)
162
163
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ # setup autoloading for Stubbing module
5
+ module Stubbing
6
+ autoload :EmptyStub, 'aws-sdk-core/stubbing/empty_stub'
7
+ autoload :DataApplicator, 'aws-sdk-core/stubbing/data_applicator'
8
+ autoload :StubData, 'aws-sdk-core/stubbing/stub_data'
9
+ autoload :XmlError, 'aws-sdk-core/stubbing/xml_error'
10
+
11
+ module Protocols
12
+ autoload :Json, 'aws-sdk-core/stubbing/protocols/json'
13
+ autoload :Rest, 'aws-sdk-core/stubbing/protocols/rest'
14
+ autoload :RestJson, 'aws-sdk-core/stubbing/protocols/rest_json'
15
+ autoload :RestXml, 'aws-sdk-core/stubbing/protocols/rest_xml'
16
+ autoload :Query, 'aws-sdk-core/stubbing/protocols/query'
17
+ autoload :EC2, 'aws-sdk-core/stubbing/protocols/ec2'
18
+ autoload :RpcV2, 'aws-sdk-core/stubbing/protocols/rpc_v2'
19
+ autoload :ApiGateway, 'aws-sdk-core/stubbing/protocols/api_gateway'
20
+ end
21
+ end
22
+ end
@@ -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
@@ -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