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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d56c9d2bed4f998ebcdc3d8749099ede72c95ea8948bc39375b776ca4c60a19
4
- data.tar.gz: bf5af54a01e30d3d699845a3c94af34bb5bfd230f7bfccc863c611594e34ea34
3
+ metadata.gz: a86c4c6fbaab797ffa640c003796e15aa76ef4f3d89ceabe77c68ecda81d3f61
4
+ data.tar.gz: d083d4e406da3673a4b7e355c5bdb1f27a404f7e0cfdaf16c7997f66a93788cc
5
5
  SHA512:
6
- metadata.gz: e2a6c0fed13608fbc523f8d8eb6f86284b10b730ea9661559d269aabbab57f05f98822f848511b76cf1a942edac0812be17966c121350a72b61f08b949b1a5b1
7
- data.tar.gz: 64a9433cf193b388212de556c614d2e62fda9a25e894b3d1fec578ef2fa9abdc0e9c0232fae60f150e290e7dcac5c95441e2dd7da58fbb31cec0ad2d861958aa
6
+ metadata.gz: abf2b797bdadaa5024b02424ceb15fab0b05bb64ddab85f26025cf2c9519873e910a2d1ef8bcabdcd051ee7f292c8afca0a2356ed84d054de2d71f067529b535
7
+ data.tar.gz: a318c1bc59465a3aafe5059746860f2effaa1404343ddf5955a3e0a5891e61f815a410e9d073afb016d2d0f0fa755cc6e167aa315468afd055cf3ed0ce415121
data/CHANGELOG.md CHANGED
@@ -1 +1,5 @@
1
1
  # Release History: opentelemetry-instrumentation-aws_sdk
2
+
3
+ ### v0.1.0 / 2021-12-01
4
+
5
+ * Initial release.
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(service_name, operation)) do |span|
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(service_name, client_method)
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.0')
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
@@ -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(context, :topic_arn)
15
- target_arn = params(context, :target_arn)
16
- phone_number = params(context, :phone_number)
17
- queue_url = params(context, :queue_url)
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(context, :queue_url)
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
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module AwsSdk
10
- VERSION = '0.1.3'
10
+ VERSION = '0.1.7'
11
11
  end
12
12
  end
13
13
  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.3
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-22 00:00:00.000000000 Z
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.18.3
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.18.3
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.0'
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.0'
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/message_attribute_setter.rb
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://github.com/open-telemetry/opentelemetry-ruby
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.3/file.CHANGELOG.html
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.3
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: