aws-sdk-core 3.202.2 → 3.203.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-core/plugins/stub_responses.rb +29 -2
- data/lib/aws-sdk-core/plugins/telemetry.rb +75 -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.rb +2 -12
- data/lib/aws-sdk-sso/client.rb +19 -2
- data/lib/aws-sdk-sso.rb +1 -1
- data/lib/aws-sdk-ssooidc/client.rb +19 -2
- data/lib/aws-sdk-ssooidc.rb +1 -1
- data/lib/aws-sdk-sts/client.rb +19 -2
- data/lib/aws-sdk-sts.rb +1 -1
- data/lib/seahorse/client/h2/handler.rb +13 -3
- data/lib/seahorse/client/net_http/handler.rb +18 -1
- data/lib/seahorse/client/request_context.rb +8 -1
- 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
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bf46cc1c58aa2eab7feaaaa91a1c3042a3fcb9737f8b752e92a2075b20c18e7
|
4
|
+
data.tar.gz: 36d04c3b40f2b9e6a235ed726c6a8bc47d6b5245204ab5cac2fd16a373602dd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 696a9df19fd3f81a85d9fdc77300ab98d13ad7aec127d892f2a81ac7994aa324d0a92164fecd63462440c11056781642a44b379e14a1f2c029b32a8c0a5c0f76
|
7
|
+
data.tar.gz: 1255facb9c4205650241f60f2469e89cc576b522f01aacb1907cf57b7c4d7bddcb28ae269b25b4608412e45b5afbd61ec1c367840aa022de7e4a208de595a3ef
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
Unreleased Changes
|
2
2
|
------------------
|
3
3
|
|
4
|
+
3.203.0 (2024-09-03)
|
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
|
+
* Feature - Add support for Observability which includes a configuration, `telemetry_provider` and an OpenTelemetry-based telemetry provider.
|
14
|
+
|
4
15
|
3.202.2 (2024-08-30)
|
5
16
|
------------------
|
6
17
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.203.0
|
@@ -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
|
62
|
-
|
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
|
@@ -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
|
@@ -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.rb
CHANGED
@@ -7,7 +7,6 @@ require 'jmespath'
|
|
7
7
|
require_relative 'aws-sdk-core/deprecations'
|
8
8
|
|
9
9
|
# credential providers
|
10
|
-
|
11
10
|
require_relative 'aws-sdk-core/credential_provider'
|
12
11
|
require_relative 'aws-sdk-core/refreshing_credentials'
|
13
12
|
require_relative 'aws-sdk-core/assume_role_credentials'
|
@@ -30,7 +29,6 @@ require_relative 'aws-sdk-core/token_provider_chain'
|
|
30
29
|
require_relative 'aws-sdk-core/plugins/bearer_authorization'
|
31
30
|
|
32
31
|
# client modules
|
33
|
-
|
34
32
|
require_relative 'aws-sdk-core/client_stubs'
|
35
33
|
require_relative 'aws-sdk-core/async_client_stubs'
|
36
34
|
require_relative 'aws-sdk-core/eager_loader'
|
@@ -45,24 +43,20 @@ require_relative 'aws-sdk-core/type_builder'
|
|
45
43
|
require_relative 'aws-sdk-core/util'
|
46
44
|
|
47
45
|
# resource classes
|
48
|
-
|
49
46
|
require_relative 'aws-sdk-core/resources/collection'
|
50
47
|
|
51
48
|
# logging
|
52
|
-
|
53
49
|
require_relative 'aws-sdk-core/log/formatter'
|
54
50
|
require_relative 'aws-sdk-core/log/param_filter'
|
55
51
|
require_relative 'aws-sdk-core/log/param_formatter'
|
56
52
|
|
57
53
|
# stubbing
|
58
|
-
|
59
54
|
require_relative 'aws-sdk-core/stubbing/empty_stub'
|
60
55
|
require_relative 'aws-sdk-core/stubbing/data_applicator'
|
61
56
|
require_relative 'aws-sdk-core/stubbing/stub_data'
|
62
57
|
require_relative 'aws-sdk-core/stubbing/xml_error'
|
63
58
|
|
64
59
|
# stubbing protocols
|
65
|
-
|
66
60
|
require_relative 'aws-sdk-core/stubbing/protocols/json'
|
67
61
|
require_relative 'aws-sdk-core/stubbing/protocols/rest'
|
68
62
|
require_relative 'aws-sdk-core/stubbing/protocols/rest_json'
|
@@ -73,7 +67,6 @@ require_relative 'aws-sdk-core/stubbing/protocols/rpc_v2'
|
|
73
67
|
require_relative 'aws-sdk-core/stubbing/protocols/api_gateway'
|
74
68
|
|
75
69
|
# protocols
|
76
|
-
|
77
70
|
require_relative 'aws-sdk-core/error_handler'
|
78
71
|
require_relative 'aws-sdk-core/rest'
|
79
72
|
require_relative 'aws-sdk-core/xml'
|
@@ -82,21 +75,18 @@ require_relative 'aws-sdk-core/query'
|
|
82
75
|
require_relative 'aws-sdk-core/rpc_v2'
|
83
76
|
|
84
77
|
# event stream
|
85
|
-
|
86
78
|
require_relative 'aws-sdk-core/binary'
|
87
79
|
require_relative 'aws-sdk-core/event_emitter'
|
88
80
|
|
89
81
|
# endpoint discovery
|
90
|
-
|
91
82
|
require_relative 'aws-sdk-core/endpoint_cache'
|
92
83
|
|
93
|
-
# client metrics
|
94
|
-
|
84
|
+
# client metrics / telemetry
|
95
85
|
require_relative 'aws-sdk-core/client_side_monitoring/request_metrics'
|
96
86
|
require_relative 'aws-sdk-core/client_side_monitoring/publisher'
|
87
|
+
require_relative 'aws-sdk-core/telemetry'
|
97
88
|
|
98
89
|
# utilities
|
99
|
-
|
100
90
|
require_relative 'aws-sdk-core/arn'
|
101
91
|
require_relative 'aws-sdk-core/arn_parser'
|
102
92
|
require_relative 'aws-sdk-core/ec2_metadata'
|
data/lib/aws-sdk-sso/client.rb
CHANGED
@@ -32,6 +32,7 @@ require 'aws-sdk-core/plugins/checksum_algorithm.rb'
|
|
32
32
|
require 'aws-sdk-core/plugins/request_compression.rb'
|
33
33
|
require 'aws-sdk-core/plugins/defaults_mode.rb'
|
34
34
|
require 'aws-sdk-core/plugins/recursion_detection.rb'
|
35
|
+
require 'aws-sdk-core/plugins/telemetry.rb'
|
35
36
|
require 'aws-sdk-core/plugins/sign.rb'
|
36
37
|
require 'aws-sdk-core/plugins/protocols/rest_json.rb'
|
37
38
|
|
@@ -83,6 +84,7 @@ module Aws::SSO
|
|
83
84
|
add_plugin(Aws::Plugins::RequestCompression)
|
84
85
|
add_plugin(Aws::Plugins::DefaultsMode)
|
85
86
|
add_plugin(Aws::Plugins::RecursionDetection)
|
87
|
+
add_plugin(Aws::Plugins::Telemetry)
|
86
88
|
add_plugin(Aws::Plugins::Sign)
|
87
89
|
add_plugin(Aws::Plugins::Protocols::RestJson)
|
88
90
|
add_plugin(Aws::SSO::Plugins::Endpoints)
|
@@ -330,6 +332,16 @@ module Aws::SSO
|
|
330
332
|
# ** Please note ** When response stubbing is enabled, no HTTP
|
331
333
|
# requests are made, and retries are disabled.
|
332
334
|
#
|
335
|
+
# @option options [Aws::Telemetry::TelemetryProviderBase] :telemetry_provider (Aws::Telemetry::NoOpTelemetryProvider)
|
336
|
+
# Allows you to provide a telemetry provider, which is used to
|
337
|
+
# emit telemetry data. By default, uses `NoOpTelemetryProvider` which
|
338
|
+
# will not record or emit any telemetry data. The SDK supports the
|
339
|
+
# following telemetry providers:
|
340
|
+
#
|
341
|
+
# * OpenTelemetry (OTel) - To use the OTel provider, install and require the
|
342
|
+
# `opentelemetry-sdk` gem and then, pass in an instance of a
|
343
|
+
# `Aws::Telemetry::OTelProvider` for telemetry provider.
|
344
|
+
#
|
333
345
|
# @option options [Aws::TokenProvider] :token_provider
|
334
346
|
# A Bearer Token Provider. This can be an instance of any one of the
|
335
347
|
# following classes:
|
@@ -635,14 +647,19 @@ module Aws::SSO
|
|
635
647
|
# @api private
|
636
648
|
def build_request(operation_name, params = {})
|
637
649
|
handlers = @handlers.for(operation_name)
|
650
|
+
tracer = config.telemetry_provider.tracer_provider.tracer(
|
651
|
+
Aws::Telemetry.module_to_tracer_name('Aws::SSO')
|
652
|
+
)
|
638
653
|
context = Seahorse::Client::RequestContext.new(
|
639
654
|
operation_name: operation_name,
|
640
655
|
operation: config.api.operation(operation_name),
|
641
656
|
client: self,
|
642
657
|
params: params,
|
643
|
-
config: config
|
658
|
+
config: config,
|
659
|
+
tracer: tracer
|
660
|
+
)
|
644
661
|
context[:gem_name] = 'aws-sdk-core'
|
645
|
-
context[:gem_version] = '3.
|
662
|
+
context[:gem_version] = '3.203.0'
|
646
663
|
Seahorse::Client::Request.new(handlers, context)
|
647
664
|
end
|
648
665
|
|
data/lib/aws-sdk-sso.rb
CHANGED
@@ -32,6 +32,7 @@ require 'aws-sdk-core/plugins/checksum_algorithm.rb'
|
|
32
32
|
require 'aws-sdk-core/plugins/request_compression.rb'
|
33
33
|
require 'aws-sdk-core/plugins/defaults_mode.rb'
|
34
34
|
require 'aws-sdk-core/plugins/recursion_detection.rb'
|
35
|
+
require 'aws-sdk-core/plugins/telemetry.rb'
|
35
36
|
require 'aws-sdk-core/plugins/sign.rb'
|
36
37
|
require 'aws-sdk-core/plugins/protocols/rest_json.rb'
|
37
38
|
|
@@ -83,6 +84,7 @@ module Aws::SSOOIDC
|
|
83
84
|
add_plugin(Aws::Plugins::RequestCompression)
|
84
85
|
add_plugin(Aws::Plugins::DefaultsMode)
|
85
86
|
add_plugin(Aws::Plugins::RecursionDetection)
|
87
|
+
add_plugin(Aws::Plugins::Telemetry)
|
86
88
|
add_plugin(Aws::Plugins::Sign)
|
87
89
|
add_plugin(Aws::Plugins::Protocols::RestJson)
|
88
90
|
add_plugin(Aws::SSOOIDC::Plugins::Endpoints)
|
@@ -330,6 +332,16 @@ module Aws::SSOOIDC
|
|
330
332
|
# ** Please note ** When response stubbing is enabled, no HTTP
|
331
333
|
# requests are made, and retries are disabled.
|
332
334
|
#
|
335
|
+
# @option options [Aws::Telemetry::TelemetryProviderBase] :telemetry_provider (Aws::Telemetry::NoOpTelemetryProvider)
|
336
|
+
# Allows you to provide a telemetry provider, which is used to
|
337
|
+
# emit telemetry data. By default, uses `NoOpTelemetryProvider` which
|
338
|
+
# will not record or emit any telemetry data. The SDK supports the
|
339
|
+
# following telemetry providers:
|
340
|
+
#
|
341
|
+
# * OpenTelemetry (OTel) - To use the OTel provider, install and require the
|
342
|
+
# `opentelemetry-sdk` gem and then, pass in an instance of a
|
343
|
+
# `Aws::Telemetry::OTelProvider` for telemetry provider.
|
344
|
+
#
|
333
345
|
# @option options [Aws::TokenProvider] :token_provider
|
334
346
|
# A Bearer Token Provider. This can be an instance of any one of the
|
335
347
|
# following classes:
|
@@ -988,14 +1000,19 @@ module Aws::SSOOIDC
|
|
988
1000
|
# @api private
|
989
1001
|
def build_request(operation_name, params = {})
|
990
1002
|
handlers = @handlers.for(operation_name)
|
1003
|
+
tracer = config.telemetry_provider.tracer_provider.tracer(
|
1004
|
+
Aws::Telemetry.module_to_tracer_name('Aws::SSOOIDC')
|
1005
|
+
)
|
991
1006
|
context = Seahorse::Client::RequestContext.new(
|
992
1007
|
operation_name: operation_name,
|
993
1008
|
operation: config.api.operation(operation_name),
|
994
1009
|
client: self,
|
995
1010
|
params: params,
|
996
|
-
config: config
|
1011
|
+
config: config,
|
1012
|
+
tracer: tracer
|
1013
|
+
)
|
997
1014
|
context[:gem_name] = 'aws-sdk-core'
|
998
|
-
context[:gem_version] = '3.
|
1015
|
+
context[:gem_version] = '3.203.0'
|
999
1016
|
Seahorse::Client::Request.new(handlers, context)
|
1000
1017
|
end
|
1001
1018
|
|
data/lib/aws-sdk-ssooidc.rb
CHANGED
data/lib/aws-sdk-sts/client.rb
CHANGED
@@ -32,6 +32,7 @@ require 'aws-sdk-core/plugins/checksum_algorithm.rb'
|
|
32
32
|
require 'aws-sdk-core/plugins/request_compression.rb'
|
33
33
|
require 'aws-sdk-core/plugins/defaults_mode.rb'
|
34
34
|
require 'aws-sdk-core/plugins/recursion_detection.rb'
|
35
|
+
require 'aws-sdk-core/plugins/telemetry.rb'
|
35
36
|
require 'aws-sdk-core/plugins/sign.rb'
|
36
37
|
require 'aws-sdk-core/plugins/protocols/query.rb'
|
37
38
|
require 'aws-sdk-sts/plugins/sts_regional_endpoints.rb'
|
@@ -84,6 +85,7 @@ module Aws::STS
|
|
84
85
|
add_plugin(Aws::Plugins::RequestCompression)
|
85
86
|
add_plugin(Aws::Plugins::DefaultsMode)
|
86
87
|
add_plugin(Aws::Plugins::RecursionDetection)
|
88
|
+
add_plugin(Aws::Plugins::Telemetry)
|
87
89
|
add_plugin(Aws::Plugins::Sign)
|
88
90
|
add_plugin(Aws::Plugins::Protocols::Query)
|
89
91
|
add_plugin(Aws::STS::Plugins::STSRegionalEndpoints)
|
@@ -337,6 +339,16 @@ module Aws::STS
|
|
337
339
|
# ** Please note ** When response stubbing is enabled, no HTTP
|
338
340
|
# requests are made, and retries are disabled.
|
339
341
|
#
|
342
|
+
# @option options [Aws::Telemetry::TelemetryProviderBase] :telemetry_provider (Aws::Telemetry::NoOpTelemetryProvider)
|
343
|
+
# Allows you to provide a telemetry provider, which is used to
|
344
|
+
# emit telemetry data. By default, uses `NoOpTelemetryProvider` which
|
345
|
+
# will not record or emit any telemetry data. The SDK supports the
|
346
|
+
# following telemetry providers:
|
347
|
+
#
|
348
|
+
# * OpenTelemetry (OTel) - To use the OTel provider, install and require the
|
349
|
+
# `opentelemetry-sdk` gem and then, pass in an instance of a
|
350
|
+
# `Aws::Telemetry::OTelProvider` for telemetry provider.
|
351
|
+
#
|
340
352
|
# @option options [Aws::TokenProvider] :token_provider
|
341
353
|
# A Bearer Token Provider. This can be an instance of any one of the
|
342
354
|
# following classes:
|
@@ -2382,14 +2394,19 @@ module Aws::STS
|
|
2382
2394
|
# @api private
|
2383
2395
|
def build_request(operation_name, params = {})
|
2384
2396
|
handlers = @handlers.for(operation_name)
|
2397
|
+
tracer = config.telemetry_provider.tracer_provider.tracer(
|
2398
|
+
Aws::Telemetry.module_to_tracer_name('Aws::STS')
|
2399
|
+
)
|
2385
2400
|
context = Seahorse::Client::RequestContext.new(
|
2386
2401
|
operation_name: operation_name,
|
2387
2402
|
operation: config.api.operation(operation_name),
|
2388
2403
|
client: self,
|
2389
2404
|
params: params,
|
2390
|
-
config: config
|
2405
|
+
config: config,
|
2406
|
+
tracer: tracer
|
2407
|
+
)
|
2391
2408
|
context[:gem_name] = 'aws-sdk-core'
|
2392
|
-
context[:gem_version] = '3.
|
2409
|
+
context[:gem_version] = '3.203.0'
|
2393
2410
|
Seahorse::Client::Request.new(handlers, context)
|
2394
2411
|
end
|
2395
2412
|
|
data/lib/aws-sdk-sts.rb
CHANGED
@@ -27,6 +27,12 @@ module Seahorse
|
|
27
27
|
class Handler < Client::Handler
|
28
28
|
|
29
29
|
def call(context)
|
30
|
+
span_wrapper(context) { _call(context) }
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def _call(context)
|
30
36
|
stream = nil
|
31
37
|
begin
|
32
38
|
conn = context.client.connection
|
@@ -80,8 +86,6 @@ module Seahorse
|
|
80
86
|
)
|
81
87
|
end
|
82
88
|
|
83
|
-
private
|
84
|
-
|
85
89
|
def _register_callbacks(resp, stream, stream_mutex, close_condition, sync_queue)
|
86
90
|
stream.on(:headers) do |headers|
|
87
91
|
resp.signal_headers(headers)
|
@@ -146,8 +150,14 @@ module Seahorse
|
|
146
150
|
end
|
147
151
|
end
|
148
152
|
|
153
|
+
def span_wrapper(context, &block)
|
154
|
+
context.tracer.in_span(
|
155
|
+
'Handler.H2',
|
156
|
+
attributes: Aws::Telemetry.http_request_attrs(context),
|
157
|
+
&block
|
158
|
+
)
|
159
|
+
end
|
149
160
|
end
|
150
|
-
|
151
161
|
end
|
152
162
|
end
|
153
163
|
end
|
@@ -42,7 +42,13 @@ module Seahorse
|
|
42
42
|
# @param [RequestContext] context
|
43
43
|
# @return [Response]
|
44
44
|
def call(context)
|
45
|
-
|
45
|
+
span_wrapper(context) do
|
46
|
+
transmit(
|
47
|
+
context.config,
|
48
|
+
context.http_request,
|
49
|
+
context.http_response
|
50
|
+
)
|
51
|
+
end
|
46
52
|
Response.new(context: context)
|
47
53
|
end
|
48
54
|
|
@@ -192,6 +198,17 @@ module Seahorse
|
|
192
198
|
end
|
193
199
|
end
|
194
200
|
|
201
|
+
def span_wrapper(context, &block)
|
202
|
+
context.tracer.in_span(
|
203
|
+
'Handler.NetHttp',
|
204
|
+
attributes: Aws::Telemetry.http_request_attrs(context)
|
205
|
+
) do |span|
|
206
|
+
block.call
|
207
|
+
span.add_attributes(
|
208
|
+
Aws::Telemetry.http_response_attrs(context)
|
209
|
+
)
|
210
|
+
end
|
211
|
+
end
|
195
212
|
end
|
196
213
|
end
|
197
214
|
end
|
@@ -9,11 +9,14 @@ module Seahorse
|
|
9
9
|
# @option options [required,Symbol] :operation_name (nil)
|
10
10
|
# @option options [required,Model::Operation] :operation (nil)
|
11
11
|
# @option options [Model::Authorizer] :authorizer (nil)
|
12
|
+
# @option options [Client] :client (nil)
|
12
13
|
# @option options [Hash] :params ({})
|
13
14
|
# @option options [Configuration] :config (nil)
|
14
15
|
# @option options [Http::Request] :http_request (Http::Request.new)
|
15
16
|
# @option options [Http::Response] :http_response (Http::Response.new)
|
16
|
-
#
|
17
|
+
# @option options [Integer] :retries (0)
|
18
|
+
# @option options [Aws::Telemetry::TracerBase] :tracer (Aws::Telemetry::NoOpTracer.new)
|
19
|
+
# @options options [Hash] :metadata ({})
|
17
20
|
def initialize(options = {})
|
18
21
|
@operation_name = options[:operation_name]
|
19
22
|
@operation = options[:operation]
|
@@ -24,6 +27,7 @@ module Seahorse
|
|
24
27
|
@http_request = options[:http_request] || Http::Request.new
|
25
28
|
@http_response = options[:http_response] || Http::Response.new
|
26
29
|
@retries = 0
|
30
|
+
@tracer = options[:tracer] || Aws::Telemetry::NoOpTracer.new
|
27
31
|
@metadata = {}
|
28
32
|
end
|
29
33
|
|
@@ -54,6 +58,9 @@ module Seahorse
|
|
54
58
|
# @return [Integer]
|
55
59
|
attr_accessor :retries
|
56
60
|
|
61
|
+
# @return [Tracer]
|
62
|
+
attr_accessor :tracer
|
63
|
+
|
57
64
|
# @return [Hash]
|
58
65
|
attr_reader :metadata
|
59
66
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Aws
|
2
|
+
module Telemetry
|
3
|
+
class TelemetryProviderBase
|
4
|
+
def initialize: (?tracer_provider: TracerProviderBase, ?context_manager: ContextManagerBase) -> void
|
5
|
+
attr_reader tracer_provider: TracerProviderBase
|
6
|
+
|
7
|
+
attr_reader context_manager: ContextManagerBase
|
8
|
+
end
|
9
|
+
|
10
|
+
class TracerProviderBase
|
11
|
+
def tracer: (?String name) -> TracerBase
|
12
|
+
end
|
13
|
+
|
14
|
+
class TracerBase
|
15
|
+
def start_span: (String name, ?untyped with_parent, ?Hash[String, untyped] attributes, ?SpanKind kind) -> SpanBase
|
16
|
+
|
17
|
+
def in_span: (String name, ?Hash[String, untyped] attributes, ?SpanKind kind) -> SpanBase
|
18
|
+
|
19
|
+
def current_span: () -> SpanBase
|
20
|
+
end
|
21
|
+
|
22
|
+
class SpanBase
|
23
|
+
def set_attribute: (String key, untyped value) -> self
|
24
|
+
alias []= set_attribute
|
25
|
+
|
26
|
+
def add_attributes: (Hash[String, untyped] attributes) -> self
|
27
|
+
|
28
|
+
def add_event: (String name, ?Hash[String, untyped] attributes) -> self
|
29
|
+
|
30
|
+
def status=: (SpanStatus status) -> void
|
31
|
+
|
32
|
+
def finish: (?Time end_timestamp) -> self
|
33
|
+
|
34
|
+
def record_exception: (untyped exception, ?Hash[String, untyped] attributes) -> void
|
35
|
+
end
|
36
|
+
|
37
|
+
class ContextManagerBase
|
38
|
+
def current: () -> untyped
|
39
|
+
|
40
|
+
def attach: (untyped context) -> untyped
|
41
|
+
|
42
|
+
def detach: (untyped token) -> bool
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Aws
|
2
|
+
module Telemetry
|
3
|
+
class OTelProvider < TelemetryProviderBase
|
4
|
+
def initialize: () -> void
|
5
|
+
end
|
6
|
+
|
7
|
+
class OTelTracerProvider < TracerProviderBase
|
8
|
+
def initialize: () -> void
|
9
|
+
end
|
10
|
+
|
11
|
+
class OTelTracer < TracerBase
|
12
|
+
def initialize: (untyped tracer) -> void
|
13
|
+
end
|
14
|
+
|
15
|
+
class OTelSpan < SpanBase
|
16
|
+
def initialize: (untyped span) -> void
|
17
|
+
end
|
18
|
+
|
19
|
+
class OTelContextManager < ContextManagerBase
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Aws
|
2
|
+
module Telemetry
|
3
|
+
class SpanStatus
|
4
|
+
|
5
|
+
def self.unset: (?::String description) -> SpanStatus
|
6
|
+
|
7
|
+
def self.ok: (?::String description) -> SpanStatus
|
8
|
+
|
9
|
+
def self.error: (?::String description) -> SpanStatus
|
10
|
+
|
11
|
+
def initialize: (Integer code, ?description: ::String) -> void
|
12
|
+
|
13
|
+
attr_reader code: Integer
|
14
|
+
|
15
|
+
attr_reader description: String
|
16
|
+
|
17
|
+
OK: 0
|
18
|
+
|
19
|
+
UNSET: 1
|
20
|
+
|
21
|
+
ERROR: 2
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.203.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jmespath
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- lib/aws-sdk-core/plugins/signature_v2.rb
|
204
204
|
- lib/aws-sdk-core/plugins/signature_v4.rb
|
205
205
|
- lib/aws-sdk-core/plugins/stub_responses.rb
|
206
|
+
- lib/aws-sdk-core/plugins/telemetry.rb
|
206
207
|
- lib/aws-sdk-core/plugins/transfer_encoding.rb
|
207
208
|
- lib/aws-sdk-core/plugins/user_agent.rb
|
208
209
|
- lib/aws-sdk-core/process_credentials.rb
|
@@ -253,6 +254,12 @@ files:
|
|
253
254
|
- lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb
|
254
255
|
- lib/aws-sdk-core/stubbing/stub_data.rb
|
255
256
|
- lib/aws-sdk-core/stubbing/xml_error.rb
|
257
|
+
- lib/aws-sdk-core/telemetry.rb
|
258
|
+
- lib/aws-sdk-core/telemetry/base.rb
|
259
|
+
- lib/aws-sdk-core/telemetry/no_op.rb
|
260
|
+
- lib/aws-sdk-core/telemetry/otel.rb
|
261
|
+
- lib/aws-sdk-core/telemetry/span_kind.rb
|
262
|
+
- lib/aws-sdk-core/telemetry/span_status.rb
|
256
263
|
- lib/aws-sdk-core/token.rb
|
257
264
|
- lib/aws-sdk-core/token_provider.rb
|
258
265
|
- lib/aws-sdk-core/token_provider_chain.rb
|
@@ -361,6 +368,10 @@ files:
|
|
361
368
|
- sig/aws-sdk-core/errors.rbs
|
362
369
|
- sig/aws-sdk-core/resources/collection.rbs
|
363
370
|
- sig/aws-sdk-core/structure.rbs
|
371
|
+
- sig/aws-sdk-core/telemetry/base.rbs
|
372
|
+
- sig/aws-sdk-core/telemetry/otel.rbs
|
373
|
+
- sig/aws-sdk-core/telemetry/span_kind.rbs
|
374
|
+
- sig/aws-sdk-core/telemetry/span_status.rbs
|
364
375
|
- sig/aws-sdk-core/waiters/errors.rbs
|
365
376
|
- sig/seahorse/client/base.rbs
|
366
377
|
- sig/seahorse/client/handler_builder.rbs
|