aspecto-opentelemetry-instrumentation-aws_sdk 0.1.8 → 0.3.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 +22 -1
- data/README.md +1 -3
- data/lib/opentelemetry/instrumentation/aws_sdk/handler.rb +15 -15
- data/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb +4 -3
- data/lib/opentelemetry/instrumentation/aws_sdk/message_attributes.rb +2 -2
- data/lib/opentelemetry/instrumentation/aws_sdk/messaging_helper.rb +7 -33
- data/lib/opentelemetry/instrumentation/aws_sdk/version.rb +1 -1
- metadata +29 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d746413b032d66731e317195aa59ab210ca9b807bb77d09efa78fec35b2f4141
|
4
|
+
data.tar.gz: 0121c5f854af58616b3bb1cb3ea4e659c46ea4c915af155aae018c232ad1ad6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22c5d870ce3ca131c05661428e4a53ab9a43feafa89265a3948b856437c2115fd6c8a493e2b52ff0104001595f59a176d5d9fbf04c78d25e688725b653284d98
|
7
|
+
data.tar.gz: 5b636bbdfad5fdb6ceb812d0ecd436f85ee4cc0c69c349cfd37482e930a3e306dd92133a646a44ea77d95f9bee225ace746067408268006d60b765112c7b03f3
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,25 @@
|
|
1
|
-
# Release History: opentelemetry-instrumentation-aws_sdk
|
1
|
+
# Release History: opentelemetry-instrumentation-aws_sdk
|
2
|
+
|
3
|
+
### v0.3.0 / 2022-06-09
|
4
|
+
|
5
|
+
* Upgrading Base dependency version
|
6
|
+
* FIXED: Broken test file requirements
|
7
|
+
|
8
|
+
### v0.2.3 / 2022-05-02
|
9
|
+
|
10
|
+
* FIXED: RubyGems Fallback
|
11
|
+
|
12
|
+
### v0.2.2 / 2022-01-26
|
13
|
+
|
14
|
+
* (No significant changes)
|
15
|
+
|
16
|
+
### v0.2.1 / 2022-01-21
|
17
|
+
|
18
|
+
* ADDED: attach HTTP status code to AWS spans
|
19
|
+
|
20
|
+
### v0.2.0 / 2022-01-20
|
21
|
+
|
22
|
+
* ADDED: SQS / SNS messaging attributes and context propagation
|
2
23
|
|
3
24
|
### v0.1.0 / 2021-12-01
|
4
25
|
|
data/README.md
CHANGED
@@ -19,7 +19,6 @@ To install the instrumentation, call `use` with the name of the instrumentation.
|
|
19
19
|
```ruby
|
20
20
|
OpenTelemetry::SDK.configure do |c|
|
21
21
|
c.use 'OpenTelemetry::Instrumentation::AwsSdk', {
|
22
|
-
extract_messaging_context: true,
|
23
22
|
inject_messaging_context: true,
|
24
23
|
suppress_internal_instrumentation: true
|
25
24
|
}
|
@@ -59,8 +58,7 @@ Apache 2.0 license. See [LICENSE][license-github] for more information.
|
|
59
58
|
[aws-sdk-home]: https://github.com/aws/aws-sdk-ruby
|
60
59
|
[bundler-home]: https://bundler.io
|
61
60
|
[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
|
62
|
-
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
|
61
|
+
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
|
63
62
|
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
|
64
63
|
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
65
64
|
[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
|
66
|
-
|
@@ -17,7 +17,7 @@ module OpenTelemetry
|
|
17
17
|
def call(context) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
18
18
|
return super unless context
|
19
19
|
|
20
|
-
service_name =
|
20
|
+
service_name = service_name(context)
|
21
21
|
operation = context.operation&.name
|
22
22
|
client_method = "#{service_name}.#{operation}"
|
23
23
|
attributes = {
|
@@ -30,21 +30,20 @@ module OpenTelemetry
|
|
30
30
|
MessagingHelper.apply_sqs_attributes(attributes, context, client_method) if service_name == 'SQS'
|
31
31
|
MessagingHelper.apply_sns_attributes(attributes, context, client_method) if service_name == 'SNS'
|
32
32
|
|
33
|
-
prepare_extract_context(context, client_method)
|
34
33
|
tracer.in_span(span_name(context, client_method), attributes: attributes, kind: span_kind(client_method)) do |span|
|
35
34
|
inject_context(context, client_method)
|
36
|
-
|
37
35
|
if instrumentation_config[:suppress_internal_instrumentation]
|
38
36
|
OpenTelemetry::Common::Utilities.untraced { super }
|
39
37
|
else
|
40
38
|
super
|
41
39
|
end.tap do |response|
|
40
|
+
span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE,
|
41
|
+
context.http_response.status_code)
|
42
|
+
|
42
43
|
if (err = response.error)
|
43
44
|
span.record_exception(err)
|
44
45
|
span.status = Trace::Status.error(err.to_s)
|
45
46
|
end
|
46
|
-
|
47
|
-
MessagingHelper.create_sqs_processing_spans(context, tracer, response.messages) if client_method == SQS_RECEIVE_MESSAGE && response.respond_to?(:messages)
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
@@ -59,8 +58,16 @@ module OpenTelemetry
|
|
59
58
|
AwsSdk::Instrumentation.instance.config
|
60
59
|
end
|
61
60
|
|
61
|
+
def service_name(context) # rubocop:disable Metrics/AbcSize
|
62
|
+
# Support aws-sdk v2.0.x, which 'metadata' has a setter method only
|
63
|
+
return context.client.class.to_s.split('::')[1] if ::Seahorse::Model::Api.instance_method(:metadata).parameters.length.positive?
|
64
|
+
|
65
|
+
context.client.class.api.metadata['serviceId'] || context.client.class.to_s.split('::')[1]
|
66
|
+
end
|
67
|
+
|
68
|
+
SEND_MESSAGE_CLIENT_METHODS = [SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH].freeze
|
62
69
|
def inject_context(context, client_method)
|
63
|
-
return unless
|
70
|
+
return unless SEND_MESSAGE_CLIENT_METHODS.include? client_method
|
64
71
|
return unless instrumentation_config[:inject_messaging_context]
|
65
72
|
|
66
73
|
if client_method == SQS_SEND_MESSAGE_BATCH
|
@@ -74,13 +81,6 @@ module OpenTelemetry
|
|
74
81
|
end
|
75
82
|
end
|
76
83
|
|
77
|
-
def prepare_extract_context(context, client_method)
|
78
|
-
return unless client_method == SQS_RECEIVE_MESSAGE
|
79
|
-
return unless instrumentation_config[:extract_messaging_context]
|
80
|
-
|
81
|
-
context.params[:message_attribute_names] = ['All']
|
82
|
-
end
|
83
|
-
|
84
84
|
def span_kind(client_method)
|
85
85
|
case client_method
|
86
86
|
when SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH
|
@@ -95,9 +95,9 @@ module OpenTelemetry
|
|
95
95
|
def span_name(context, client_method)
|
96
96
|
case client_method
|
97
97
|
when SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH
|
98
|
-
"#{MessagingHelper.
|
98
|
+
"#{MessagingHelper.queue_name(context)} send"
|
99
99
|
when SQS_RECEIVE_MESSAGE
|
100
|
-
"#{MessagingHelper.
|
100
|
+
"#{MessagingHelper.queue_name(context)} receive"
|
101
101
|
else
|
102
102
|
client_method
|
103
103
|
end
|
@@ -9,7 +9,7 @@ module OpenTelemetry
|
|
9
9
|
module AwsSdk
|
10
10
|
# Instrumentation class that detects and installs the AwsSdk instrumentation
|
11
11
|
class Instrumentation < OpenTelemetry::Instrumentation::Base
|
12
|
-
MINIMUM_VERSION = Gem::Version.new('2.0')
|
12
|
+
MINIMUM_VERSION = Gem::Version.new('2.0.0')
|
13
13
|
|
14
14
|
install do |_config|
|
15
15
|
require_dependencies
|
@@ -21,10 +21,9 @@ module OpenTelemetry
|
|
21
21
|
end
|
22
22
|
|
23
23
|
compatible do
|
24
|
-
gem_version >= MINIMUM_VERSION
|
24
|
+
!gem_version.nil? && gem_version >= MINIMUM_VERSION
|
25
25
|
end
|
26
26
|
|
27
|
-
option :extract_messaging_context, default: false, validate: :boolean
|
28
27
|
option :inject_messaging_context, default: false, validate: :boolean
|
29
28
|
option :suppress_internal_instrumentation, default: false, validate: :boolean
|
30
29
|
|
@@ -33,6 +32,8 @@ module OpenTelemetry
|
|
33
32
|
Gem.loaded_specs['aws-sdk'].version
|
34
33
|
elsif Gem.loaded_specs['aws-sdk-core']
|
35
34
|
Gem.loaded_specs['aws-sdk-core'].version
|
35
|
+
elsif defined?(::Aws::CORE_GEM_VERSION)
|
36
|
+
Gem::Version.new(::Aws::CORE_GEM_VERSION)
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
@@ -26,10 +26,10 @@ module OpenTelemetry
|
|
26
26
|
# The MessageAttributeGetter class provides methods for getting tracing information from SQS message.
|
27
27
|
#
|
28
28
|
# @example
|
29
|
-
# OpenTelemetry.propagation.extract(message
|
29
|
+
# OpenTelemetry.propagation.extract(message, getter: MessageAttributeGetter)
|
30
30
|
class MessageAttributeGetter
|
31
31
|
def self.get(carrier, key)
|
32
|
-
return carrier
|
32
|
+
return carrier[key][:string_value] if carrier[key][:data_type] == 'String'
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -10,23 +10,19 @@ module OpenTelemetry
|
|
10
10
|
# MessagingHelper class provides methods for calculating messaging span attributes
|
11
11
|
class MessagingHelper
|
12
12
|
class << self
|
13
|
-
def
|
13
|
+
def queue_name(context)
|
14
14
|
topic_arn = context.params[:topic_arn]
|
15
15
|
target_arn = context.params[:target_arn]
|
16
|
-
phone_number = context.params[:phone_number]
|
17
|
-
queue_url = context.params[:queue_url]
|
18
16
|
|
19
17
|
if topic_arn || target_arn
|
20
18
|
arn = topic_arn || target_arn
|
21
|
-
|
22
|
-
return arn.split(':')[-1]
|
23
|
-
rescue StandardError
|
24
|
-
return arn
|
25
|
-
end
|
19
|
+
return arn.split(':')[-1]
|
26
20
|
end
|
27
21
|
|
22
|
+
phone_number = context.params[:phone_number]
|
28
23
|
return 'phone_number' if phone_number
|
29
24
|
|
25
|
+
queue_url = context.params[:queue_url]
|
30
26
|
return queue_url.split('/')[-1] if queue_url
|
31
27
|
|
32
28
|
'unknown'
|
@@ -35,8 +31,8 @@ module OpenTelemetry
|
|
35
31
|
def apply_sqs_attributes(attributes, context, client_method)
|
36
32
|
attributes[SemanticConventions::Trace::MESSAGING_SYSTEM] = 'aws.sqs'
|
37
33
|
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION_KIND] = 'queue'
|
38
|
-
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION] =
|
39
|
-
attributes[SemanticConventions::Trace::MESSAGING_URL] = context.params[:queue_url]
|
34
|
+
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION] = queue_name(context)
|
35
|
+
attributes[SemanticConventions::Trace::MESSAGING_URL] = context.params[:queue_url] if context.params[:queue_url]
|
40
36
|
|
41
37
|
attributes[SemanticConventions::Trace::MESSAGING_OPERATION] = 'receive' if client_method == 'SQS.ReceiveMessage'
|
42
38
|
end
|
@@ -47,29 +43,7 @@ module OpenTelemetry
|
|
47
43
|
return unless client_method == 'SNS.Publish'
|
48
44
|
|
49
45
|
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION_KIND] = 'topic'
|
50
|
-
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION] =
|
51
|
-
end
|
52
|
-
|
53
|
-
def create_sqs_processing_spans(context, tracer, messages)
|
54
|
-
queue_name = destination_name(context)
|
55
|
-
messages.each do |message|
|
56
|
-
attributes = {
|
57
|
-
SemanticConventions::Trace::MESSAGING_SYSTEM => 'aws.sqs',
|
58
|
-
SemanticConventions::Trace::MESSAGING_DESTINATION => queue_name,
|
59
|
-
SemanticConventions::Trace::MESSAGING_DESTINATION_KIND => 'queue',
|
60
|
-
SemanticConventions::Trace::MESSAGING_MESSAGE_ID => message.message_id,
|
61
|
-
SemanticConventions::Trace::MESSAGING_URL => context.params[:queue_url],
|
62
|
-
SemanticConventions::Trace::MESSAGING_OPERATION => 'process'
|
63
|
-
}
|
64
|
-
tracer.in_span("#{queue_name} process", attributes: attributes, links: extract_links(message), kind: :consumer) {}
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def extract_links(sqs_message)
|
69
|
-
extracted_context = OpenTelemetry.propagation.extract(sqs_message.message_attributes, context: Context::ROOT, getter: MessageAttributeGetter)
|
70
|
-
span_context = OpenTelemetry::Trace.current_span(extracted_context).context
|
71
|
-
|
72
|
-
span_context.valid? ? [OpenTelemetry::Trace::Link.new(span_context)] : []
|
46
|
+
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION] = queue_name(context)
|
73
47
|
end
|
74
48
|
end
|
75
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aspecto-opentelemetry-instrumentation-aws_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- OpenTelemetry Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.21.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.21.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: appraisal
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,28 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
103
|
+
version: '1.1'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
110
|
+
version: '1.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: opentelemetry-test-helpers
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: pry
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -222,7 +236,7 @@ dependencies:
|
|
222
236
|
version: 0.1.6
|
223
237
|
description: AWS SDK instrumentation for the OpenTelemetry framework
|
224
238
|
email:
|
225
|
-
-
|
239
|
+
- cncf-opentelemetry-contributors@lists.cncf.io
|
226
240
|
executables: []
|
227
241
|
extensions: []
|
228
242
|
extra_rdoc_files: []
|
@@ -240,14 +254,14 @@ files:
|
|
240
254
|
- lib/opentelemetry/instrumentation/aws_sdk/messaging_helper.rb
|
241
255
|
- lib/opentelemetry/instrumentation/aws_sdk/services.rb
|
242
256
|
- lib/opentelemetry/instrumentation/aws_sdk/version.rb
|
243
|
-
homepage: https://
|
257
|
+
homepage: https://github.com/open-telemetry/opentelemetry-contrib
|
244
258
|
licenses:
|
245
259
|
- Apache-2.0
|
246
260
|
metadata:
|
247
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-aws_sdk/v0.
|
248
|
-
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/aws_sdk
|
249
|
-
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
250
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-aws_sdk/v0.
|
261
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-aws_sdk/v0.3.0/file.CHANGELOG.html
|
262
|
+
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/aws_sdk
|
263
|
+
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
264
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-aws_sdk/v0.3.0
|
251
265
|
post_install_message:
|
252
266
|
rdoc_options: []
|
253
267
|
require_paths:
|
@@ -256,14 +270,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
256
270
|
requirements:
|
257
271
|
- - ">="
|
258
272
|
- !ruby/object:Gem::Version
|
259
|
-
version: 2.
|
273
|
+
version: 2.6.0
|
260
274
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
275
|
requirements:
|
262
276
|
- - ">="
|
263
277
|
- !ruby/object:Gem::Version
|
264
278
|
version: '0'
|
265
279
|
requirements: []
|
266
|
-
rubygems_version: 3.0.3
|
280
|
+
rubygems_version: 3.0.3.1
|
267
281
|
signing_key:
|
268
282
|
specification_version: 4
|
269
283
|
summary: AWS SDK instrumentation for the OpenTelemetry framework
|