aspecto-opentelemetry-instrumentation-aws_sdk 0.1.2 → 0.1.6
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/lib/opentelemetry/instrumentation/aws_sdk/handler.rb +43 -54
- data/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb +10 -6
- data/lib/opentelemetry/instrumentation/aws_sdk/messaging_helper.rb +16 -31
- data/lib/opentelemetry/instrumentation/aws_sdk/version.rb +1 -1
- metadata +11 -12
- data/lib/opentelemetry/instrumentation/aws_sdk/db_helper.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa597e2aa47ee5d20cdd7aab2b10f63cf1dc8398fc54f94711cbd19e52b98ef7
|
4
|
+
data.tar.gz: 3e16982a6f39cd0a25227bee2fdf6d8643608136fcc289bb40f56ab386f6b57b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e6f17dbc025657d0137c92e617c594c562fa6850ff16028fa63fcf19f8000c61c89a54d495de01be0ecd2cf63d7ad65cef89748715b51b4bff8e577430258b8
|
7
|
+
data.tar.gz: 8d3efebc1b9fd5a383397f5c70fa764967b2fc4afdb88fec9547d6f6599fb5ec72c3d3ca49fbf54969dc9f772c53a15e8bb94efe12c850608cb8c7b73e69f4e8
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
# Release History: opentelemetry-instrumentation-aws_sdk
|
@@ -14,60 +14,62 @@ module OpenTelemetry
|
|
14
14
|
SQS_RECEIVE_MESSAGE = 'SQS.ReceiveMessage'
|
15
15
|
SNS_PUBLISH = 'SNS.Publish'
|
16
16
|
|
17
|
-
def call(context)
|
18
|
-
|
19
|
-
attributes = get_span_attributes(context)
|
17
|
+
def call(context) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
18
|
+
return super unless context
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
20
|
+
service_name = context.client.class.to_s.split('::')[1]
|
21
|
+
operation = context.operation&.name
|
22
|
+
client_method = "#{service_name}.#{operation}"
|
23
|
+
attributes = {
|
24
|
+
'aws.region' => context.config.region,
|
25
|
+
OpenTelemetry::SemanticConventions::Trace::RPC_SYSTEM => 'aws-api',
|
26
|
+
OpenTelemetry::SemanticConventions::Trace::RPC_METHOD => operation,
|
27
|
+
OpenTelemetry::SemanticConventions::Trace::RPC_SERVICE => service_name
|
28
|
+
}
|
29
|
+
attributes[SemanticConventions::Trace::DB_SYSTEM] = 'dynamodb' if service_name == 'DynamoDB'
|
30
|
+
MessagingHelper.apply_sqs_attributes(attributes, context, client_method) if service_name == 'SQS'
|
31
|
+
MessagingHelper.apply_sns_attributes(attributes, context, client_method) if service_name == 'SNS'
|
31
32
|
|
33
|
+
tracer.in_span(span_name(context, client_method), attributes: attributes, kind: span_kind(client_method)) do |span|
|
34
|
+
inject_context(context, client_method)
|
32
35
|
if instrumentation_config[:suppress_internal_instrumentation]
|
33
|
-
OpenTelemetry::Common::Utilities.untraced
|
36
|
+
OpenTelemetry::Common::Utilities.untraced { super }
|
34
37
|
else
|
35
|
-
|
38
|
+
super
|
39
|
+
end.tap do |response|
|
40
|
+
if (err = response.error)
|
41
|
+
span.record_exception(err)
|
42
|
+
span.status = Trace::Status.error(err.to_s)
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
39
47
|
|
40
|
-
|
41
|
-
client_method = get_client_method(context)
|
42
|
-
return unless [SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH].include? client_method
|
48
|
+
private
|
43
49
|
|
44
|
-
|
45
|
-
|
50
|
+
def tracer
|
51
|
+
AwsSdk::Instrumentation.instance.tracer
|
46
52
|
end
|
47
53
|
|
48
|
-
def
|
49
|
-
|
50
|
-
'aws.region' => context.config.region,
|
51
|
-
OpenTelemetry::SemanticConventions::Trace::RPC_SYSTEM => 'aws-api',
|
52
|
-
OpenTelemetry::SemanticConventions::Trace::RPC_METHOD => get_operation(context),
|
53
|
-
OpenTelemetry::SemanticConventions::Trace::RPC_SERVICE => get_service_name(context)
|
54
|
-
}
|
55
|
-
|
56
|
-
messaging_attributes = MessagingHelper.get_messaging_attributes(context, get_service_name(context), get_operation(context))
|
57
|
-
db_attributes = DbHelper.get_db_attributes(context, get_service_name(context), get_operation(context))
|
58
|
-
span_attributes.merge(messaging_attributes).merge(db_attributes)
|
54
|
+
def instrumentation_config
|
55
|
+
AwsSdk::Instrumentation.instance.config
|
59
56
|
end
|
60
57
|
|
61
|
-
def
|
62
|
-
|
63
|
-
end
|
58
|
+
def inject_context(context, client_method)
|
59
|
+
return unless [SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH].include? client_method
|
64
60
|
|
65
|
-
|
66
|
-
|
61
|
+
if client_method == SQS_SEND_MESSAGE_BATCH
|
62
|
+
context.params[:entries].each do |entry|
|
63
|
+
entry[:message_attributes] ||= {}
|
64
|
+
OpenTelemetry.propagation.inject(entry[:message_attributes], setter: MessageAttributeSetter)
|
65
|
+
end
|
66
|
+
else
|
67
|
+
context.params[:message_attributes] ||= {}
|
68
|
+
OpenTelemetry.propagation.inject(context.params[:message_attributes], setter: MessageAttributeSetter)
|
69
|
+
end
|
67
70
|
end
|
68
71
|
|
69
|
-
def
|
70
|
-
client_method = get_client_method(context)
|
72
|
+
def span_kind(client_method)
|
71
73
|
case client_method
|
72
74
|
when SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH
|
73
75
|
OpenTelemetry::Trace::SpanKind::PRODUCER
|
@@ -78,29 +80,16 @@ module OpenTelemetry
|
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
81
|
-
def
|
82
|
-
client_method = get_client_method(context)
|
83
|
+
def span_name(context, client_method)
|
83
84
|
case client_method
|
84
85
|
when SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH
|
85
|
-
"#{MessagingHelper.
|
86
|
+
"#{MessagingHelper.queue_name(context)} send"
|
86
87
|
when SQS_RECEIVE_MESSAGE
|
87
|
-
"#{MessagingHelper.
|
88
|
+
"#{MessagingHelper.queue_name(context)} receive"
|
88
89
|
else
|
89
90
|
client_method
|
90
91
|
end
|
91
92
|
end
|
92
|
-
|
93
|
-
def get_client_method(context)
|
94
|
-
"#{get_service_name(context)}.#{get_operation(context)}"
|
95
|
-
end
|
96
|
-
|
97
|
-
def tracer
|
98
|
-
AwsSdk::Instrumentation.instance.tracer
|
99
|
-
end
|
100
|
-
|
101
|
-
def instrumentation_config
|
102
|
-
AwsSdk::Instrumentation.instance.config
|
103
|
-
end
|
104
93
|
end
|
105
94
|
|
106
95
|
# A Seahorse::Client::Plugin that enables instrumentation for all AWS services
|
@@ -12,12 +12,7 @@ module OpenTelemetry
|
|
12
12
|
MINIMUM_VERSION = Gem::Version.new('2.0')
|
13
13
|
|
14
14
|
install do |_config|
|
15
|
-
|
16
|
-
require_relative 'services'
|
17
|
-
require_relative 'message_attribute_setter'
|
18
|
-
require_relative 'messaging_helper'
|
19
|
-
require_relative 'db_helper'
|
20
|
-
|
15
|
+
require_dependencies
|
21
16
|
add_plugin(Seahorse::Client::Base, *loaded_constants)
|
22
17
|
end
|
23
18
|
|
@@ -31,6 +26,15 @@ module OpenTelemetry
|
|
31
26
|
|
32
27
|
option :suppress_internal_instrumentation, default: false, validate: :boolean
|
33
28
|
|
29
|
+
private
|
30
|
+
|
31
|
+
def require_dependencies
|
32
|
+
require_relative 'handler'
|
33
|
+
require_relative 'services'
|
34
|
+
require_relative 'message_attribute_setter'
|
35
|
+
require_relative 'messaging_helper'
|
36
|
+
end
|
37
|
+
|
34
38
|
def gem_version
|
35
39
|
if Gem.loaded_specs['aws-sdk']
|
36
40
|
Gem.loaded_specs['aws-sdk'].version
|
@@ -10,11 +10,11 @@ module OpenTelemetry
|
|
10
10
|
# MessagingHelper class provides methods for calculating messaging span attributes
|
11
11
|
class MessagingHelper
|
12
12
|
class << self
|
13
|
-
def
|
14
|
-
topic_arn = context.
|
15
|
-
target_arn = context.
|
16
|
-
phone_number = context.
|
17
|
-
queue_url = context.
|
13
|
+
def queue_name(context) # rubocop:disable Metrics/CyclomaticComplexity
|
14
|
+
topic_arn = context.params[:topic_arn]
|
15
|
+
target_arn = context.params[:target_arn]
|
16
|
+
phone_number = context.params[:phone_number]
|
17
|
+
queue_url = context.params[:queue_url]
|
18
18
|
|
19
19
|
if topic_arn || target_arn
|
20
20
|
arn = topic_arn || target_arn
|
@@ -32,37 +32,22 @@ module OpenTelemetry
|
|
32
32
|
'unknown'
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
35
|
+
def apply_sqs_attributes(attributes, context, client_method)
|
36
|
+
attributes[SemanticConventions::Trace::MESSAGING_SYSTEM] = 'aws.sqs'
|
37
|
+
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION_KIND] = 'queue'
|
38
|
+
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION] = queue_name(context)
|
39
|
+
attributes[SemanticConventions::Trace::MESSAGING_URL] = context.params[:queue_url]
|
38
40
|
|
39
|
-
|
41
|
+
attributes[SemanticConventions::Trace::MESSAGING_OPERATION] = 'receive' if client_method == 'SQS.ReceiveMessage'
|
40
42
|
end
|
41
43
|
|
42
|
-
def
|
43
|
-
|
44
|
-
SemanticConventions::Trace::MESSAGING_SYSTEM => 'aws.sqs',
|
45
|
-
SemanticConventions::Trace::MESSAGING_DESTINATION_KIND => 'queue',
|
46
|
-
SemanticConventions::Trace::MESSAGING_DESTINATION => get_queue_name(context),
|
47
|
-
SemanticConventions::Trace::MESSAGING_URL => context.metadata[:original_params][:queue_url]
|
48
|
-
}
|
44
|
+
def apply_sns_attributes(attributes, context, client_method)
|
45
|
+
attributes[SemanticConventions::Trace::MESSAGING_SYSTEM] = 'aws.sns'
|
49
46
|
|
50
|
-
|
47
|
+
return unless client_method == 'SNS.Publish'
|
51
48
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
def get_sns_attributes(context, operation)
|
56
|
-
sns_attributes = {
|
57
|
-
SemanticConventions::Trace::MESSAGING_SYSTEM => 'aws.sns'
|
58
|
-
}
|
59
|
-
|
60
|
-
if operation == 'Publish'
|
61
|
-
sns_attributes[SemanticConventions::Trace::MESSAGING_DESTINATION_KIND] = 'topic'
|
62
|
-
sns_attributes[SemanticConventions::Trace::MESSAGING_DESTINATION] = get_queue_name(context)
|
63
|
-
end
|
64
|
-
|
65
|
-
sns_attributes
|
49
|
+
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION_KIND] = 'topic'
|
50
|
+
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION] = queue_name(context)
|
66
51
|
end
|
67
52
|
end
|
68
53
|
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.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Aspecto Authors
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -222,7 +222,7 @@ dependencies:
|
|
222
222
|
version: 0.1.6
|
223
223
|
description: AWS SDK instrumentation for the OpenTelemetry framework
|
224
224
|
email:
|
225
|
-
-
|
225
|
+
- info@aspecto.io
|
226
226
|
executables: []
|
227
227
|
extensions: []
|
228
228
|
extra_rdoc_files: []
|
@@ -234,22 +234,21 @@ files:
|
|
234
234
|
- lib/opentelemetry-instrumentation-aws_sdk.rb
|
235
235
|
- lib/opentelemetry/instrumentation.rb
|
236
236
|
- lib/opentelemetry/instrumentation/aws_sdk.rb
|
237
|
-
- lib/opentelemetry/instrumentation/aws_sdk/db_helper.rb
|
238
237
|
- lib/opentelemetry/instrumentation/aws_sdk/handler.rb
|
239
238
|
- lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb
|
240
239
|
- lib/opentelemetry/instrumentation/aws_sdk/message_attribute_setter.rb
|
241
240
|
- lib/opentelemetry/instrumentation/aws_sdk/messaging_helper.rb
|
242
241
|
- lib/opentelemetry/instrumentation/aws_sdk/services.rb
|
243
242
|
- lib/opentelemetry/instrumentation/aws_sdk/version.rb
|
244
|
-
homepage: https://
|
243
|
+
homepage: https://aspecto.io
|
245
244
|
licenses:
|
246
245
|
- Apache-2.0
|
247
246
|
metadata:
|
248
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-aws_sdk/v0.1.
|
247
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-aws_sdk/v0.1.6/file.CHANGELOG.html
|
249
248
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/aws_sdk
|
250
249
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
251
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-aws_sdk/v0.1.
|
252
|
-
post_install_message:
|
250
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-aws_sdk/v0.1.6
|
251
|
+
post_install_message:
|
253
252
|
rdoc_options: []
|
254
253
|
require_paths:
|
255
254
|
- lib
|
@@ -264,8 +263,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
263
|
- !ruby/object:Gem::Version
|
265
264
|
version: '0'
|
266
265
|
requirements: []
|
267
|
-
rubygems_version: 3.
|
268
|
-
signing_key:
|
266
|
+
rubygems_version: 3.0.3
|
267
|
+
signing_key:
|
269
268
|
specification_version: 4
|
270
269
|
summary: AWS SDK instrumentation for the OpenTelemetry framework
|
271
270
|
test_files: []
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright The OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
module OpenTelemetry
|
8
|
-
module Instrumentation
|
9
|
-
module AwsSdk
|
10
|
-
# DbHelper class provides methods for calculating aws db span attributes
|
11
|
-
class DbHelper
|
12
|
-
class << self
|
13
|
-
def get_db_attributes(context, service_name, operation)
|
14
|
-
return get_dynamodb_attributes(context, operation) if service_name == 'DynamoDB'
|
15
|
-
|
16
|
-
{}
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_dynamodb_attributes(context, operation)
|
20
|
-
{
|
21
|
-
SemanticConventions::Trace::DB_SYSTEM => 'dynamodb'
|
22
|
-
}
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|