aspecto-opentelemetry-instrumentation-aws_sdk 0.1.3 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -0
- data/lib/opentelemetry/instrumentation/aws_sdk/handler.rb +4 -3
- data/lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb +11 -10
- data/lib/opentelemetry/instrumentation/aws_sdk/{message_attribute_setter.rb → message_attributes.rb} +10 -0
- data/lib/opentelemetry/instrumentation/aws_sdk/messaging_helper.rb +6 -10
- data/lib/opentelemetry/instrumentation/aws_sdk/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a86c4c6fbaab797ffa640c003796e15aa76ef4f3d89ceabe77c68ecda81d3f61
|
4
|
+
data.tar.gz: d083d4e406da3673a4b7e355c5bdb1f27a404f7e0cfdaf16c7997f66a93788cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abf2b797bdadaa5024b02424ceb15fab0b05bb64ddab85f26025cf2c9519873e910a2d1ef8bcabdcd051ee7f292c8afca0a2356ed84d054de2d71f067529b535
|
7
|
+
data.tar.gz: a318c1bc59465a3aafe5059746860f2effaa1404343ddf5955a3e0a5891e61f815a410e9d073afb016d2d0f0fa755cc6e167aa315468afd055cf3ed0ce415121
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -19,6 +19,7 @@ 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
|
+
inject_messaging_context: true,
|
22
23
|
suppress_internal_instrumentation: true
|
23
24
|
}
|
24
25
|
end
|
@@ -30,7 +30,7 @@ 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
|
-
tracer.in_span(span_name(context, client_method), attributes: attributes, kind: span_kind(
|
33
|
+
tracer.in_span(span_name(context, client_method), attributes: attributes, kind: span_kind(client_method)) do |span|
|
34
34
|
inject_context(context, client_method)
|
35
35
|
if instrumentation_config[:suppress_internal_instrumentation]
|
36
36
|
OpenTelemetry::Common::Utilities.untraced { super }
|
@@ -39,7 +39,7 @@ module OpenTelemetry
|
|
39
39
|
end.tap do |response|
|
40
40
|
if (err = response.error)
|
41
41
|
span.record_exception(err)
|
42
|
-
span.status = Trace::Status.error(err)
|
42
|
+
span.status = Trace::Status.error(err.to_s)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -57,6 +57,7 @@ module OpenTelemetry
|
|
57
57
|
|
58
58
|
def inject_context(context, client_method)
|
59
59
|
return unless [SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH].include? client_method
|
60
|
+
return unless instrumentation_config[:inject_messaging_context]
|
60
61
|
|
61
62
|
if client_method == SQS_SEND_MESSAGE_BATCH
|
62
63
|
context.params[:entries].each do |entry|
|
@@ -69,7 +70,7 @@ module OpenTelemetry
|
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
72
|
-
def span_kind(
|
73
|
+
def span_kind(client_method)
|
73
74
|
case client_method
|
74
75
|
when SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH
|
75
76
|
OpenTelemetry::Trace::SpanKind::PRODUCER
|
@@ -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.
|
12
|
+
MINIMUM_VERSION = Gem::Version.new('2.1')
|
13
13
|
|
14
14
|
install do |_config|
|
15
15
|
require_dependencies
|
@@ -24,17 +24,9 @@ module OpenTelemetry
|
|
24
24
|
gem_version >= MINIMUM_VERSION
|
25
25
|
end
|
26
26
|
|
27
|
+
option :inject_messaging_context, default: false, validate: :boolean
|
27
28
|
option :suppress_internal_instrumentation, default: false, validate: :boolean
|
28
29
|
|
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
|
-
|
38
30
|
def gem_version
|
39
31
|
if Gem.loaded_specs['aws-sdk']
|
40
32
|
Gem.loaded_specs['aws-sdk'].version
|
@@ -43,6 +35,15 @@ module OpenTelemetry
|
|
43
35
|
end
|
44
36
|
end
|
45
37
|
|
38
|
+
private
|
39
|
+
|
40
|
+
def require_dependencies
|
41
|
+
require_relative 'handler'
|
42
|
+
require_relative 'services'
|
43
|
+
require_relative 'message_attributes'
|
44
|
+
require_relative 'messaging_helper'
|
45
|
+
end
|
46
|
+
|
46
47
|
def add_plugin(*targets)
|
47
48
|
targets.each { |klass| klass.add_plugin(AwsSdk::Plugin) }
|
48
49
|
end
|
data/lib/opentelemetry/instrumentation/aws_sdk/{message_attribute_setter.rb → message_attributes.rb}
RENAMED
@@ -22,6 +22,16 @@ module OpenTelemetry
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
# The MessageAttributeGetter class provides methods for getting tracing information from SQS message.
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# OpenTelemetry.propagation.extract(message, getter: MessageAttributeGetter)
|
30
|
+
class MessageAttributeGetter
|
31
|
+
def self.get(carrier, key)
|
32
|
+
return carrier[key][:string_value] if carrier[key][:data_type] == 'String'
|
33
|
+
end
|
34
|
+
end
|
25
35
|
end
|
26
36
|
end
|
27
37
|
end
|
@@ -11,10 +11,10 @@ module OpenTelemetry
|
|
11
11
|
class MessagingHelper
|
12
12
|
class << self
|
13
13
|
def queue_name(context) # rubocop:disable Metrics/CyclomaticComplexity
|
14
|
-
topic_arn = params
|
15
|
-
target_arn = params
|
16
|
-
phone_number = params
|
17
|
-
queue_url = params
|
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
|
@@ -25,7 +25,7 @@ module OpenTelemetry
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
return phone_number if phone_number
|
28
|
+
return 'phone_number' if phone_number
|
29
29
|
|
30
30
|
return queue_url.split('/')[-1] if queue_url
|
31
31
|
|
@@ -36,7 +36,7 @@ module OpenTelemetry
|
|
36
36
|
attributes[SemanticConventions::Trace::MESSAGING_SYSTEM] = 'aws.sqs'
|
37
37
|
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION_KIND] = 'queue'
|
38
38
|
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION] = queue_name(context)
|
39
|
-
attributes[SemanticConventions::Trace::MESSAGING_URL] = params
|
39
|
+
attributes[SemanticConventions::Trace::MESSAGING_URL] = context.params[:queue_url]
|
40
40
|
|
41
41
|
attributes[SemanticConventions::Trace::MESSAGING_OPERATION] = 'receive' if client_method == 'SQS.ReceiveMessage'
|
42
42
|
end
|
@@ -49,10 +49,6 @@ module OpenTelemetry
|
|
49
49
|
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION_KIND] = 'topic'
|
50
50
|
attributes[SemanticConventions::Trace::MESSAGING_DESTINATION] = queue_name(context)
|
51
51
|
end
|
52
|
-
|
53
|
-
def params(context, param)
|
54
|
-
defined?(context.metadata[:original_params][param]) ? context.metadata[:original_params][param] : context.params[param]
|
55
|
-
end
|
56
52
|
end
|
57
53
|
end
|
58
54
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aspecto Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-13 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.19.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.19.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: appraisal
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '2.
|
61
|
+
version: '2.1'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '2.
|
68
|
+
version: '2.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -236,18 +236,18 @@ files:
|
|
236
236
|
- lib/opentelemetry/instrumentation/aws_sdk.rb
|
237
237
|
- lib/opentelemetry/instrumentation/aws_sdk/handler.rb
|
238
238
|
- lib/opentelemetry/instrumentation/aws_sdk/instrumentation.rb
|
239
|
-
- lib/opentelemetry/instrumentation/aws_sdk/
|
239
|
+
- lib/opentelemetry/instrumentation/aws_sdk/message_attributes.rb
|
240
240
|
- lib/opentelemetry/instrumentation/aws_sdk/messaging_helper.rb
|
241
241
|
- lib/opentelemetry/instrumentation/aws_sdk/services.rb
|
242
242
|
- lib/opentelemetry/instrumentation/aws_sdk/version.rb
|
243
|
-
homepage: https://
|
243
|
+
homepage: https://aspecto.io
|
244
244
|
licenses:
|
245
245
|
- Apache-2.0
|
246
246
|
metadata:
|
247
|
-
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.7/file.CHANGELOG.html
|
248
248
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/aws_sdk
|
249
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.1.
|
250
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-aws_sdk/v0.1.7
|
251
251
|
post_install_message:
|
252
252
|
rdoc_options: []
|
253
253
|
require_paths:
|