instana 1.195.1 → 1.195.2

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: 4c351d84ce6a119088dfddccf06c02957186ae496065ab79e410d69fd1d83779
4
- data.tar.gz: 1e1b17f30b3dd4addb48608acdca47459f5bf28ba3d86600e0029b0ad4650ecc
3
+ metadata.gz: 6ecd5d44386711b77f9063712fe05c1831771a9c6740c429d75244ed31594730
4
+ data.tar.gz: a9babf1b336a2502f0d0b9c1bacd5a8e1283519b02f5d32aea8e58523d50d766
5
5
  SHA512:
6
- metadata.gz: 33cba90ad6ca8665d087657748fe2989712b067c1483dc34756e9cd734faf5421a48070e339ae47b3bf4033762d43805e3b8f20948df584ddb756aad5a6ded03
7
- data.tar.gz: 443b3675bc9807a7bed8449be5c9dd4d58a2bc220274ec146904aff3576688da636e2d6cf75842800788b31ec2ea5b7fb85db0841a93cbed35a64d67b7cde862
6
+ metadata.gz: 84916aa5ce872b6d309a5b6b97b50e469b98f7a0cae67c29d2be4904e7f120aa464b85b88b4fac4329165d8f77ea7783066a766d69f5809fd85faa1ad989640f
7
+ data.tar.gz: c94e2ef1d5d72362c64355be70cef8a9835bbe23acd14da29a57c11918c1df0fffafa3ea494a4d87d9349318588d3bc0ee1c6ae5dc9a1b21c3a07271cf487b6f
data/.circleci/config.yml CHANGED
@@ -11,6 +11,10 @@ executors:
11
11
  - image: memcached
12
12
  - image: redis
13
13
  - image: circleci/dynamodb
14
+ - image: minio/minio:latest
15
+ command: ["server", "/data"]
16
+ - image: s12v/sns
17
+ - image: softwaremill/elasticmq-native
14
18
  ruby_26:
15
19
  docker:
16
20
  - image: circleci/ruby:2.6-node
@@ -21,6 +25,10 @@ executors:
21
25
  - image: memcached
22
26
  - image: redis
23
27
  - image: circleci/dynamodb
28
+ - image: minio/minio:latest
29
+ command: ["server", "/data"]
30
+ - image: s12v/sns
31
+ - image: softwaremill/elasticmq-native
24
32
  ruby_27:
25
33
  docker:
26
34
  - image: circleci/ruby:2.7-node
@@ -31,6 +39,10 @@ executors:
31
39
  - image: memcached
32
40
  - image: redis
33
41
  - image: circleci/dynamodb
42
+ - image: minio/minio:latest
43
+ command: ["server", "/data"]
44
+ - image: s12v/sns
45
+ - image: softwaremill/elasticmq-native
34
46
  ruby_25_mysql2:
35
47
  docker:
36
48
  - image: circleci/ruby:2.5-node
@@ -159,10 +171,10 @@ jobs:
159
171
  parameters:
160
172
  stack:
161
173
  type: executor
162
- default: ruby_27_postgres
174
+ default: ruby_27
163
175
  gemfile:
164
176
  type: string
165
- default: "./gemfiles/rails_60.gemfile"
177
+ default: "./gemfiles/aws_30.gemfile"
166
178
  executor: << parameters.stack >>
167
179
  environment:
168
180
  APPRAISAL_INITIALIZED: "1"
@@ -203,6 +215,7 @@ workflows:
203
215
  - "./gemfiles/cuba_30.gemfile"
204
216
  - "./gemfiles/dalli_20.gemfile"
205
217
  - "./gemfiles/excon_02.gemfile"
218
+ - "./gemfiles/excon_079.gemfile"
206
219
  - "./gemfiles/graphql_10.gemfile"
207
220
  - "./gemfiles/grpc_10.gemfile"
208
221
  - "./gemfiles/net_http_01.gemfile"
@@ -218,6 +231,7 @@ workflows:
218
231
  - "./gemfiles/sidekiq_42.gemfile"
219
232
  - "./gemfiles/sidekiq_50.gemfile"
220
233
  - "./gemfiles/sinatra_14.gemfile"
234
+ - "./gemfiles/shoryuken_50.gemfile"
221
235
  rails:
222
236
  jobs:
223
237
  - test_apprisal:
data/Appraisals CHANGED
@@ -3,6 +3,9 @@
3
3
 
4
4
  appraise 'aws-30' do
5
5
  gem 'aws-sdk-dynamodb', '~> 1.59'
6
+ gem 'aws-sdk-s3', '~> 1.59'
7
+ gem 'aws-sdk-sns', '~> 1.38'
8
+ gem 'aws-sdk-sqs', '~> 1.36'
6
9
  end
7
10
 
8
11
  appraise 'cuba-30' do
@@ -13,10 +16,14 @@ appraise 'dalli-20' do
13
16
  gem 'dalli', '>= 2.0', '< 3.0'
14
17
  end
15
18
 
16
- appraise 'excon-02' do
19
+ appraise 'excon-021' do
17
20
  gem 'excon', '>= 0.21.0', '< 1.0'
18
21
  end
19
22
 
23
+ appraise 'excon-079' do
24
+ gem 'excon', '>= 0.79.0', '< 1.0'
25
+ end
26
+
20
27
  appraise 'grpc-10' do
21
28
  gem 'grpc', '>= 1.0', '< 2.0'
22
29
  end
@@ -98,6 +105,11 @@ appraise 'sinatra-14' do
98
105
  gem 'sinatra', '1.4.7'
99
106
  end
100
107
 
108
+ appraise 'shoryuken-50' do
109
+ gem 'shoryuken', '~> 5.2'
110
+ gem 'aws-sdk-sqs', '~> 1.36'
111
+ end
112
+
101
113
  appraise 'sidekiq-42' do
102
114
  gem 'sidekiq', '~> 4.2.10'
103
115
  end
@@ -0,0 +1,20 @@
1
+ version: '3'
2
+ services:
3
+ sns:
4
+ image: s12v/sns
5
+ ports:
6
+ - "9911:9911"
7
+ s3:
8
+ image: minio/minio:latest
9
+ command: ["server", "/data"]
10
+ ports:
11
+ - "9000:9000"
12
+ dynamodb:
13
+ image: circleci/dynamodb
14
+ ports:
15
+ - "8000:8000"
16
+ sqs:
17
+ image: softwaremill/elasticmq-native
18
+ ports:
19
+ - "9324:9324"
20
+ - "9325:9325"
@@ -14,5 +14,8 @@ gem "rubocop", "~> 1.9"
14
14
  gem "rack-test"
15
15
  gem "simplecov", "~> 0.21.2"
16
16
  gem "aws-sdk-dynamodb", "~> 1.59"
17
+ gem "aws-sdk-s3", "~> 1.59"
18
+ gem "aws-sdk-sns", "~> 1.38"
19
+ gem "aws-sdk-sqs", "~> 1.36"
17
20
 
18
21
  gemspec path: "../"
@@ -0,0 +1,18 @@
1
+ # This file was generated by Appraisal
2
+
3
+ # (c) Copyright IBM Corp. 2021
4
+ # (c) Copyright Instana Inc. 2021
5
+
6
+ source "https://rubygems.org"
7
+
8
+ gem "rake"
9
+ gem "minitest", "5.9.1"
10
+ gem "minitest-reporters"
11
+ gem "webmock"
12
+ gem "puma"
13
+ gem "rubocop", "~> 1.9"
14
+ gem "rack-test"
15
+ gem "simplecov", "~> 0.21.2"
16
+ gem "excon", ">= 0.21.0", "< 1.0"
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,18 @@
1
+ # This file was generated by Appraisal
2
+
3
+ # (c) Copyright IBM Corp. 2021
4
+ # (c) Copyright Instana Inc. 2021
5
+
6
+ source "https://rubygems.org"
7
+
8
+ gem "rake"
9
+ gem "minitest", "5.9.1"
10
+ gem "minitest-reporters"
11
+ gem "webmock"
12
+ gem "puma"
13
+ gem "rubocop", "~> 1.9"
14
+ gem "rack-test"
15
+ gem "simplecov", "~> 0.21.2"
16
+ gem "excon", ">= 0.79.0", "< 1.0"
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,19 @@
1
+ # This file was generated by Appraisal
2
+
3
+ # (c) Copyright IBM Corp. 2021
4
+ # (c) Copyright Instana Inc. 2021
5
+
6
+ source "https://rubygems.org"
7
+
8
+ gem "rake"
9
+ gem "minitest", "5.9.1"
10
+ gem "minitest-reporters"
11
+ gem "webmock"
12
+ gem "puma"
13
+ gem "rubocop", "~> 1.9"
14
+ gem "rack-test"
15
+ gem "simplecov", "~> 0.21.2"
16
+ gem "shoryuken", "~> 5.2"
17
+ gem "aws-sdk-sqs", "~> 1.36"
18
+
19
+ gemspec path: "../"
@@ -0,0 +1,20 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Activators
6
+ class AwsS3 < Activator
7
+ def can_instrument?
8
+ defined?(Aws::S3::Client)
9
+ end
10
+
11
+ def instrument
12
+ require 'instana/instrumentation/aws_sdk_s3'
13
+
14
+ ::Aws::S3::Client.add_plugin(Instana::Instrumentation::S3)
15
+
16
+ true
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Activators
6
+ class AwsSdkSns < Activator
7
+ def can_instrument?
8
+ defined?(Aws::SNS::Client)
9
+ end
10
+
11
+ def instrument
12
+ require 'instana/instrumentation/aws_sdk_sns'
13
+
14
+ ::Aws::SNS::Client.add_plugin(Instana::Instrumentation::SNS)
15
+
16
+ true
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Activators
6
+ class AwsSdkSqs < Activator
7
+ def can_instrument?
8
+ defined?(Aws::SQS::Client)
9
+ end
10
+
11
+ def instrument
12
+ require 'instana/instrumentation/aws_sdk_sqs'
13
+
14
+ ::Aws::SQS::Client.add_plugin(Instana::Instrumentation::SQS)
15
+
16
+ true
17
+ end
18
+ end
19
+ end
20
+ end
@@ -5,7 +5,7 @@ module Instana
5
5
  module Activators
6
6
  class Excon < Activator
7
7
  def can_instrument?
8
- defined?(::Excon) && defined?(::Excon::Middleware::Base) && Instana.config[:excon][:enabled]
8
+ defined?(::Excon) && defined?(::Excon::Middleware::Base) && ::Excon.respond_to?(:defaults) && Instana.config[:excon][:enabled]
9
9
  end
10
10
 
11
11
  def instrument
@@ -0,0 +1,24 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Activators
6
+ class Shoryuken < Activator
7
+ def can_instrument?
8
+ defined?(::Shoryuken) && ::Shoryuken.respond_to?(:configure_server)
9
+ end
10
+
11
+ def instrument
12
+ require 'instana/instrumentation/shoryuken'
13
+
14
+ ::Shoryuken.configure_server do |config|
15
+ config.server_middleware do |chain|
16
+ chain.add ::Instana::Instrumentation::Shoryuken
17
+ end
18
+ end
19
+
20
+ true
21
+ end
22
+ end
23
+ end
24
+ end
@@ -7,11 +7,11 @@ module Instana
7
7
  class Handler < Seahorse::Client::Handler
8
8
  def call(context)
9
9
  dynamo_tags = {
10
- op: context.operation_name,
10
+ op: format_operation(context.operation_name),
11
11
  table: table_name_from(context)
12
12
  }
13
13
 
14
- ::Instana.tracer.trace(:dynamodb, dynamo_tags) { @handler.call(context) }
14
+ ::Instana.tracer.trace(:dynamodb, {dynamodb: dynamo_tags}) { @handler.call(context) }
15
15
  end
16
16
 
17
17
  private
@@ -19,6 +19,25 @@ module Instana
19
19
  def table_name_from(context)
20
20
  context.params[:table_name] || context.params[:global_table_name] || 'Unknown'
21
21
  end
22
+
23
+ def format_operation(name)
24
+ case name
25
+ when :create_table
26
+ 'create'
27
+ when :list_tables
28
+ 'list'
29
+ when :get_item
30
+ 'get'
31
+ when :put_item
32
+ 'put'
33
+ when :update_item
34
+ 'update'
35
+ when :delete_item
36
+ 'delete'
37
+ else
38
+ name.to_s
39
+ end
40
+ end
22
41
  end
23
42
 
24
43
  def add_handlers(handlers, _config)
@@ -0,0 +1,55 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Instrumentation
6
+ class S3 < Seahorse::Client::Plugin
7
+ class Handler < Seahorse::Client::Handler
8
+ def call(context)
9
+ s3_tags = {
10
+ op: format_operation(context.operation_name),
11
+ bucket: bucket_name_from(context),
12
+ key: key_from_context(context)
13
+ }.compact
14
+
15
+ ::Instana.tracer.trace(:s3, {s3: s3_tags}) { @handler.call(context) }
16
+ end
17
+
18
+ private
19
+
20
+ def bucket_name_from(context)
21
+ context.params[:bucket] || 'Unknown'
22
+ end
23
+
24
+ def key_from_context(context)
25
+ context.params[:key]
26
+ end
27
+
28
+ def format_operation(name)
29
+ case name
30
+ when :create_bucket
31
+ 'createBucket'
32
+ when :delete_bucket
33
+ 'deleteBucket'
34
+ when :delete_object
35
+ 'delete'
36
+ when :get_object
37
+ 'get'
38
+ when :head_object
39
+ 'metadata'
40
+ when :list_objects
41
+ 'list'
42
+ when :put_object
43
+ 'list'
44
+ else
45
+ name.to_s
46
+ end
47
+ end
48
+ end
49
+
50
+ def add_handlers(handlers, _config)
51
+ handlers.add(Handler, step: :initialize)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,29 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Instrumentation
6
+ class SNS < Seahorse::Client::Plugin
7
+ class Handler < Seahorse::Client::Handler
8
+ def call(context)
9
+ sns_tags = {
10
+ topic: context.params[:topic_arn],
11
+ target: context.params[:target_arn],
12
+ phone: context.params[:phone_number],
13
+ subject: context.params[:subject]
14
+ }.compact
15
+
16
+ if context.operation_name == :publish
17
+ ::Instana.tracer.trace(:sns, {sns: sns_tags}) { @handler.call(context) }
18
+ else
19
+ @handler.call(context)
20
+ end
21
+ end
22
+ end
23
+
24
+ def add_handlers(handlers, _config)
25
+ handlers.add(Handler, step: :initialize)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,98 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Instrumentation
6
+ class SQS < Seahorse::Client::Plugin
7
+ class Handler < Seahorse::Client::Handler
8
+ SPAN_FORMING_OPERATIONS = [:send_message, :send_message_batch, :get_queue_url, :create_queue, :delete_message, :delete_message_batch].freeze
9
+
10
+ def call(context)
11
+ is_tracing = ::Instana.tracer.tracing?
12
+ unless is_tracing && SPAN_FORMING_OPERATIONS.include?(context.operation_name)
13
+ return @handler.call(context)
14
+ end
15
+
16
+ span_tags = tags_for(context.operation_name, context.params).compact
17
+
18
+ ::Instana.tracer.trace(:sqs, {sqs: span_tags}) do |span|
19
+ case context.operation_name
20
+ when :send_message
21
+ inject_instana_headers(span, context.params)
22
+ when :send_message_batch
23
+ context.params[:entries].each { |e| inject_instana_headers(span, e) }
24
+ end
25
+
26
+ response = @handler.call(context)
27
+
28
+ span_tags[:queue] = response.queue_url if response.respond_to?(:queue_url)
29
+ span.set_tags(sqs: span_tags)
30
+
31
+ response
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def inject_instana_headers(span, params)
38
+ params[:message_attributes] ||= {}
39
+ params[:message_attributes].merge!({
40
+ "X_INSTANA_T" => {data_type: 'String', string_value: span.context.trace_id},
41
+ "X_INSTANA_S" => {data_type: 'String', string_value: span.context.span_id},
42
+ "X_INSTANA_L" => {data_type: 'String', string_value: span.context.level.to_s}
43
+ })
44
+ end
45
+
46
+ def tags_for(operation_name, params)
47
+ case operation_name
48
+ when :create_queue
49
+ {
50
+ sort: 'exit',
51
+ type: 'create.queue',
52
+ queue: params[:queue_name]
53
+ }
54
+ when :get_queue_url
55
+ {
56
+ sort: 'exit',
57
+ type: 'get.queue',
58
+ queue: params[:queue_name]
59
+ }
60
+ when :send_message
61
+ {
62
+ sort: 'exit',
63
+ type: 'single.sync',
64
+ queue: params[:queue_url],
65
+ group: params[:message_group_id]
66
+ }
67
+ when :send_message_batch
68
+ {
69
+ sort: 'exit',
70
+ type: 'single.sync',
71
+ queue: params[:queue_url],
72
+ size: params[:entries].count
73
+ }
74
+ when :delete_message
75
+ {
76
+ sort: 'exit',
77
+ type: 'delete.single.sync',
78
+ queue: params[:queue_url]
79
+ }
80
+ when :delete_message_batch
81
+ {
82
+ sort: 'exit',
83
+ type: 'delete.batch.sync',
84
+ queue: params[:queue_url],
85
+ size: params[:entries].count
86
+ }
87
+ else
88
+ {}
89
+ end
90
+ end
91
+ end
92
+
93
+ def add_handlers(handlers, _config)
94
+ handlers.add(Handler, step: :initialize)
95
+ end
96
+ end
97
+ end
98
+ end
@@ -8,9 +8,10 @@ module Instana
8
8
  return @stack.request_call(datum) unless ::Instana.tracer.tracing? || !Instana.tracer.current_span.exit_span?
9
9
 
10
10
  payload = { :http => {} }
11
- path = datum[:path].split('?').first
11
+ path, query = datum[:path].split('?', 2)
12
12
  payload[:http][:url] = ::Instana.secrets.remove_from_query("#{datum[:connection].instance_variable_get(:@socket_key)}#{path}")
13
13
  payload[:http][:method] = datum[:method] if datum.key?(:method)
14
+ payload[:http][:params] = ::Instana.secrets.remove_from_query(query || '')
14
15
 
15
16
  if datum[:pipeline] == true
16
17
  # Pass the context along in the datum so we get back on response
@@ -46,12 +46,17 @@ module Instana
46
46
  headers
47
47
  end
48
48
 
49
+ def request_params
50
+ ::Instana.secrets.remove_from_query(@env['QUERY_STRING'])
51
+ end
52
+
49
53
  def request_tags
50
54
  {
51
55
  method: request_method,
52
56
  url: CGI.unescape(path_info),
53
57
  host: host_with_port,
54
- header: extra_header_tags
58
+ header: extra_header_tags,
59
+ params: request_params
55
60
  }.compact
56
61
  end
57
62
 
@@ -88,7 +93,7 @@ module Instana
88
93
  {
89
94
  external_trace_id: matches['trace'],
90
95
  external_state: @env['HTTP_TRACESTATE'],
91
- trace_id: ::Instana::Util.header_to_id(matches['trace'][16..-1]),
96
+ trace_id: ::Instana::Util.header_to_id(matches['trace'][16..-1]), # rubocop:disable Style/SlicingWithRange, Lint/RedundantCopDisableDirective
92
97
  span_id: ::Instana::Util.header_to_id(matches['parent'])
93
98
  }
94
99
  end
@@ -32,7 +32,9 @@ module Instana
32
32
  kv_payload[:http][:method] = request.method
33
33
 
34
34
  if request.uri
35
- kv_payload[:http][:url] = request.uri.to_s
35
+ uri_without_query = request.uri.dup.tap { |r| r.query = nil }
36
+ kv_payload[:http][:url] = uri_without_query.to_s.gsub(/\?\z/, '')
37
+ kv_payload[:http][:params] = ::Instana.secrets.remove_from_query(request.uri.query)
36
38
  else
37
39
  if use_ssl?
38
40
  kv_payload[:http][:url] = "https://#{@address}:#{@port}#{request.path}"
@@ -41,7 +43,7 @@ module Instana
41
43
  end
42
44
  end
43
45
 
44
- kv_payload[:http][:url] = ::Instana.secrets.remove_from_query(kv_payload[:http][:url])
46
+ kv_payload[:http][:url] = ::Instana.secrets.remove_from_query(kv_payload[:http][:url]).gsub(/\?\z/, '')
45
47
 
46
48
  # The core call
47
49
  response = super(*args, &block)
@@ -0,0 +1,44 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Instrumentation
6
+ class Shoryuken
7
+ def call(_worker_instance, _queue, sqs_message, _body, &block)
8
+ if sqs_message.is_a? Array
9
+ return yield
10
+ end
11
+
12
+ sqs_tags = {
13
+ sort: 'entry',
14
+ queue: sqs_message.queue_url
15
+ }
16
+
17
+ context = incomming_context_from(sqs_message.message_attributes)
18
+ ::Instana.tracer.start_or_continue_trace(:sqs, {sqs: sqs_tags}, context, &block)
19
+ end
20
+
21
+ private
22
+
23
+ def incomming_context_from(attributes)
24
+ trace_id = try(attributes, 'X_INSTANA_T', 'X_INSTANA_ST')
25
+ span_id = try(attributes, 'X_INSTANA_S', 'X_INSTANA_SS')
26
+ level = try(attributes, 'X_INSTANA_L', 'X_INSTANA_SL')
27
+
28
+ {
29
+ trace_id: trace_id,
30
+ span_id: span_id,
31
+ level: level
32
+ }.compact
33
+ end
34
+
35
+ def try(attributes, *args)
36
+ key = args.detect do |a|
37
+ attributes && attributes[a] && attributes[a].respond_to?(:string_value)
38
+ end
39
+
40
+ attributes[key].string_value if attributes && key
41
+ end
42
+ end
43
+ end
44
+ end
@@ -10,7 +10,7 @@ module Instana
10
10
  return str unless secret_values
11
11
 
12
12
  url = URI(str)
13
- params = CGI.parse(url.query || '')
13
+ params = url.scheme ? CGI.parse(url.query || '') : CGI.parse(url.to_s)
14
14
 
15
15
  redacted = params.map do |k, v|
16
16
  needs_redaction = secret_values['list']
@@ -19,7 +19,7 @@ module Instana
19
19
  end
20
20
 
21
21
  url.query = URI.encode_www_form(redacted)
22
- CGI.unescape(url.to_s)
22
+ url.scheme ? CGI.unescape(url.to_s) : CGI.unescape(url.query)
23
23
  end
24
24
 
25
25
  private
@@ -38,8 +38,8 @@ module Instana
38
38
  # :level specifies data collection level (optional)
39
39
  #
40
40
  def start_or_continue_trace(name, kvs = {}, incoming_context = nil, &block)
41
- log_start_or_continue(name, kvs, incoming_context)
42
- yield
41
+ span = log_start_or_continue(name, kvs, incoming_context)
42
+ yield(span)
43
43
  rescue Exception => e
44
44
  log_error(e)
45
45
  raise
@@ -59,8 +59,8 @@ module Instana
59
59
  # @param kvs [Hash] list of key values to be reported in this new span
60
60
  #
61
61
  def trace(name, kvs = {}, &block)
62
- log_entry(name, kvs)
63
- yield
62
+ span = log_entry(name, kvs)
63
+ yield(span)
64
64
  rescue Exception => e
65
65
  log_error(e)
66
66
  raise
@@ -6,10 +6,10 @@ module Instana
6
6
  REGISTERED_SPANS = [ :actioncontroller, :actionview, :activerecord, :excon,
7
7
  :memcache, :'net-http', :rack, :render, :'rpc-client',
8
8
  :'rpc-server', :'sidekiq-client', :'sidekiq-worker',
9
- :redis, :'resque-client', :'resque-worker', :'graphql.server', :dynamodb ].freeze
10
- ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server' ].freeze
9
+ :redis, :'resque-client', :'resque-worker', :'graphql.server', :dynamodb, :s3, :sns, :sqs ].freeze
10
+ ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server', :sqs ].freeze
11
11
  EXIT_SPANS = [ :activerecord, :excon, :'net-http', :'resque-client',
12
- :'rpc-client', :'sidekiq-client', :redis, :dynamodb ].freeze
12
+ :'rpc-client', :'sidekiq-client', :redis, :dynamodb, :s3, :sns, :sqs ].freeze
13
13
  HTTP_SPANS = [ :rack, :excon, :'net-http' ].freeze
14
14
 
15
15
  attr_accessor :parent
@@ -6,6 +6,7 @@ module Instana
6
6
  attr_accessor :trace_id
7
7
  attr_accessor :span_id
8
8
  attr_accessor :baggage
9
+ attr_reader :level
9
10
 
10
11
  # Create a new SpanContext
11
12
  #
@@ -42,7 +43,7 @@ module Instana
42
43
  def trace_state_header
43
44
  return '' unless valid?
44
45
 
45
- state = ["in=#{@trace_id};#{@span_id}", @baggage[:external_state]]
46
+ state = ["in=#{trace_id_header};#{span_id_header}", @baggage[:external_state]]
46
47
  state.compact.join(',')
47
48
  end
48
49
 
@@ -2,6 +2,6 @@
2
2
  # (c) Copyright Instana Inc. 2016
3
3
 
4
4
  module Instana
5
- VERSION = "1.195.1"
5
+ VERSION = "1.195.2"
6
6
  VERSION_FULL = "instana-#{VERSION}"
7
7
  end
@@ -4,6 +4,10 @@
4
4
  require 'test_helper'
5
5
 
6
6
  class AwsTest < Minitest::Test
7
+ def setup
8
+ clear_all!
9
+ end
10
+
7
11
  def test_dynamo_db
8
12
  dynamo = Aws::DynamoDB::Client.new(
9
13
  region: "local",
@@ -27,7 +31,131 @@ class AwsTest < Minitest::Test
27
31
  assert rest.empty?
28
32
  assert_equal entry_span[:s], dynamo_span[:p]
29
33
  assert_equal :dynamodb, dynamo_span[:n]
30
- assert_equal :get_item, dynamo_span[:data][:op]
31
- assert_equal 'sample_table', dynamo_span[:data][:table]
34
+ assert_equal 'get', dynamo_span[:data][:dynamodb][:op]
35
+ assert_equal 'sample_table', dynamo_span[:data][:dynamodb][:table]
36
+ end
37
+
38
+ def test_s3
39
+ dynamo = Aws::S3::Client.new(
40
+ region: "local",
41
+ access_key_id: "minioadmin",
42
+ secret_access_key: "minioadmin",
43
+ endpoint: "http://localhost:9000"
44
+ )
45
+
46
+ assert_raises Aws::S3::Errors::NoSuchBucket do
47
+ Instana::Tracer.start_or_continue_trace(:s3_test, {}) do
48
+ dynamo.get_object(
49
+ bucket: 'sample_bucket',
50
+ key: 'sample_key'
51
+ )
52
+ end
53
+ end
54
+
55
+ spans = ::Instana.processor.queued_spans
56
+ s3_span, entry_span, *rest = spans
57
+
58
+ assert rest.empty?
59
+ assert_equal entry_span[:s], s3_span[:p]
60
+ assert_equal :s3, s3_span[:n]
61
+ assert_equal 'get', s3_span[:data][:s3][:op]
62
+ assert_equal 'sample_bucket', s3_span[:data][:s3][:bucket]
63
+ assert_equal 'sample_key', s3_span[:data][:s3][:key]
64
+ end
65
+
66
+ def test_sns_publish
67
+ sns = Aws::SNS::Client.new(
68
+ region: "local",
69
+ access_key_id: "test",
70
+ secret_access_key: "test",
71
+ endpoint: "http://localhost:9911"
72
+ )
73
+
74
+ assert_raises Aws::SNS::Errors::NotFound do
75
+ Instana::Tracer.start_or_continue_trace(:sns_test, {}) do
76
+ sns.publish(
77
+ topic_arn: 'topic:arn',
78
+ target_arn: 'target:arn',
79
+ phone_number: '555-0100',
80
+ subject: 'Test Subject',
81
+ message: 'Test Message'
82
+ )
83
+ end
84
+ end
85
+
86
+ spans = ::Instana.processor.queued_spans
87
+ aws_span, entry_span, *rest = spans
88
+
89
+ assert rest.empty?
90
+ assert_equal entry_span[:s], aws_span[:p]
91
+ assert_equal :sns, aws_span[:n]
92
+ assert_equal 'topic:arn', aws_span[:data][:sns][:topic]
93
+ assert_equal 'target:arn', aws_span[:data][:sns][:target]
94
+ assert_equal '555-0100', aws_span[:data][:sns][:phone]
95
+ assert_equal 'Test Subject', aws_span[:data][:sns][:subject]
96
+ end
97
+
98
+ def test_sns_other
99
+ sns = Aws::SNS::Client.new(
100
+ region: "local",
101
+ access_key_id: "test",
102
+ secret_access_key: "test",
103
+ endpoint: "http://localhost:9911"
104
+ )
105
+
106
+ Instana::Tracer.start_or_continue_trace(:sns_test, {}) do
107
+ sns.list_subscriptions
108
+ end
109
+
110
+ spans = ::Instana.processor.queued_spans
111
+ aws_span, entry_span, *rest = spans
112
+
113
+ assert rest.empty?
114
+ assert_equal entry_span[:s], aws_span[:p]
115
+ assert_equal :"net-http", aws_span[:n]
116
+ end
117
+
118
+ def test_sqs
119
+ sqs = Aws::SQS::Client.new(
120
+ region: "local",
121
+ access_key_id: "test",
122
+ secret_access_key: "test",
123
+ endpoint: "http://localhost:9324"
124
+ )
125
+
126
+ create_response = nil
127
+ get_url_response = nil
128
+
129
+ Instana::Tracer.start_or_continue_trace(:sqs_test, {}) do
130
+ create_response = sqs.create_queue(queue_name: 'test')
131
+ get_url_response = sqs.get_queue_url(queue_name: 'test')
132
+ sqs.send_message(queue_url: create_response.queue_url, message_body: 'Sample')
133
+ end
134
+
135
+ received = sqs.receive_message(
136
+ queue_url: create_response.queue_url,
137
+ message_attribute_names: ['All']
138
+ )
139
+ sqs.delete_queue(queue_url: create_response.queue_url)
140
+ message = received.messages.first
141
+ create_span, get_span, send_span, _root = ::Instana.processor.queued_spans
142
+
143
+ assert_equal :sqs, create_span[:n]
144
+ assert_equal create_response.queue_url, create_span[:data][:sqs][:queue]
145
+ assert_equal 'exit', create_span[:data][:sqs][:sort]
146
+ assert_equal 'create.queue', create_span[:data][:sqs][:type]
147
+
148
+ assert_equal :sqs, get_span[:n]
149
+ assert_equal get_url_response.queue_url, get_span[:data][:sqs][:queue]
150
+ assert_equal 'exit', get_span[:data][:sqs][:sort]
151
+ assert_equal 'get.queue', get_span[:data][:sqs][:type]
152
+
153
+ assert_equal :sqs, send_span[:n]
154
+ assert_equal get_url_response.queue_url, send_span[:data][:sqs][:queue]
155
+ assert_equal 'exit', send_span[:data][:sqs][:sort]
156
+ assert_equal 'single.sync', send_span[:data][:sqs][:type]
157
+ assert_equal send_span[:t], message.message_attributes['X_INSTANA_T'].string_value
158
+ assert_equal send_span[:s], message.message_attributes['X_INSTANA_S'].string_value
159
+ assert_equal 'Sample', message.body
32
160
  end
33
161
  end
@@ -40,6 +40,7 @@ class ExconTest < Minitest::Test
40
40
  refute_nil excon_span[:data].key?(:http)
41
41
  assert_equal "http://127.0.0.1:6511/", excon_span[:data][:http][:url]
42
42
  assert_equal 200, excon_span[:data][:http][:status]
43
+ assert_equal 'basic_get', excon_span[:data][:http][:params]
43
44
 
44
45
  # excon backtrace not included by default check
45
46
  assert !excon_span.key?(:stack)
@@ -11,6 +11,24 @@ class NetHTTPTest < Minitest::Test
11
11
  assert_equal true, ::Instana.config[:nethttp][:enabled]
12
12
  end
13
13
 
14
+ def test_get_with_query
15
+ clear_all!
16
+ WebMock.allow_net_connect!
17
+
18
+ Instana.tracer.start_or_continue_trace(:"net-http-test") do
19
+ Net::HTTP.get(URI('http://127.0.0.1:6511/?query_value=true'))
20
+ end
21
+
22
+ spans = ::Instana.processor.queued_spans
23
+ assert_equal 3, spans.length
24
+
25
+ http_span = find_first_span_by_name(spans, :'net-http')
26
+ assert_equal "http://127.0.0.1:6511/", http_span[:data][:http][:url]
27
+ assert_equal "query_value=true", http_span[:data][:http][:params]
28
+
29
+ WebMock.disable_net_connect!
30
+ end
31
+
14
32
  def test_block_request
15
33
  clear_all!
16
34
  WebMock.allow_net_connect!
@@ -86,7 +86,8 @@ class RackInstrumentedRequestTest < Minitest::Test
86
86
  'HTTP_HOST' => 'example.com',
87
87
  'REQUEST_METHOD' => 'GET',
88
88
  'HTTP_X_CAPTURE_THIS' => 'that',
89
- 'PATH_INFO' => '/'
89
+ 'PATH_INFO' => '/',
90
+ 'QUERY_STRING' => 'test=true'
90
91
  )
91
92
 
92
93
  expected = {
@@ -95,7 +96,8 @@ class RackInstrumentedRequestTest < Minitest::Test
95
96
  host: 'example.com',
96
97
  header: {
97
98
  "X-Capture-This": 'that'
98
- }
99
+ },
100
+ params: 'test=true'
99
101
  }
100
102
 
101
103
  assert_equal expected, req.request_tags
@@ -0,0 +1,47 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ require 'test_helper'
5
+ require 'ostruct'
6
+
7
+ class ShoryukenTest < Minitest::Test
8
+ def setup
9
+ clear_all!
10
+ @middleware = Instana::Instrumentation::Shoryuken.new
11
+ end
12
+
13
+ def test_start_trace_with_context
14
+ id = Instana::Util.generate_id
15
+ message = OpenStruct.new(
16
+ queue_url: 'http://example.com',
17
+ message_attributes: {
18
+ "X_INSTANA_T" => OpenStruct.new(string_value: id),
19
+ "X_INSTANA_S" => OpenStruct.new(string_value: id),
20
+ "X_INSTANA_L" => OpenStruct.new(string_value: '1')
21
+ }
22
+ )
23
+
24
+ @middleware.call(nil, nil, message, nil) {}
25
+
26
+ span = ::Instana.processor.queued_spans.first
27
+
28
+ assert_equal id, span[:t]
29
+ assert_equal id, span[:p]
30
+ assert_equal 'entry', span[:data][:sqs][:sort]
31
+ assert_equal 'http://example.com', span[:data][:sqs][:queue]
32
+ end
33
+
34
+ def test_start_trace
35
+ message = OpenStruct.new(
36
+ queue_url: 'http://example.com'
37
+ )
38
+
39
+ @middleware.call(nil, nil, message, nil) {}
40
+
41
+ span = ::Instana.processor.queued_spans.first
42
+
43
+ assert_nil span[:p]
44
+ assert_equal 'entry', span[:data][:sqs][:sort]
45
+ assert_equal 'http://example.com', span[:data][:sqs][:queue]
46
+ end
47
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.195.1
4
+ version: 1.195.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Giacomo Lombardo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-25 00:00:00.000000000 Z
11
+ date: 2021-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -153,7 +153,6 @@ files:
153
153
  - ".rubocop.yml"
154
154
  - ".rubocop_todo.yml"
155
155
  - Appraisals
156
- - Dockerfile
157
156
  - Gemfile
158
157
  - LICENSE
159
158
  - README.md
@@ -168,6 +167,7 @@ files:
168
167
  - benchmarks/time_processing.rb
169
168
  - bin/console
170
169
  - bin/setup
170
+ - docker-compose.yml
171
171
  - examples/opentracing.rb
172
172
  - examples/tracing.rb
173
173
  - extras/license_header.rb
@@ -176,6 +176,8 @@ files:
176
176
  - gemfiles/cuba_30.gemfile
177
177
  - gemfiles/dalli_20.gemfile
178
178
  - gemfiles/excon_02.gemfile
179
+ - gemfiles/excon_021.gemfile
180
+ - gemfiles/excon_079.gemfile
179
181
  - gemfiles/graphql_10.gemfile
180
182
  - gemfiles/grpc_10.gemfile
181
183
  - gemfiles/net_http_01.gemfile
@@ -192,6 +194,7 @@ files:
192
194
  - gemfiles/rest_client_20.gemfile
193
195
  - gemfiles/roda_20.gemfile
194
196
  - gemfiles/roda_30.gemfile
197
+ - gemfiles/shoryuken_50.gemfile
195
198
  - gemfiles/sidekiq_42.gemfile
196
199
  - gemfiles/sidekiq_50.gemfile
197
200
  - gemfiles/sinatra_14.gemfile
@@ -204,6 +207,9 @@ files:
204
207
  - lib/instana/activators/action_view.rb
205
208
  - lib/instana/activators/active_record.rb
206
209
  - lib/instana/activators/aws_sdk_dynamodb.rb
210
+ - lib/instana/activators/aws_sdk_s3.rb
211
+ - lib/instana/activators/aws_sdk_sns.rb
212
+ - lib/instana/activators/aws_sdk_sqs.rb
207
213
  - lib/instana/activators/cuba.rb
208
214
  - lib/instana/activators/dalli.rb
209
215
  - lib/instana/activators/excon.rb
@@ -218,6 +224,7 @@ files:
218
224
  - lib/instana/activators/resque_worker.rb
219
225
  - lib/instana/activators/rest_client.rb
220
226
  - lib/instana/activators/roda.rb
227
+ - lib/instana/activators/shoryuken.rb
221
228
  - lib/instana/activators/sidekiq_client.rb
222
229
  - lib/instana/activators/sidekiq_worker.rb
223
230
  - lib/instana/activators/sinatra.rb
@@ -243,6 +250,9 @@ files:
243
250
  - lib/instana/instrumentation/action_view.rb
244
251
  - lib/instana/instrumentation/active_record.rb
245
252
  - lib/instana/instrumentation/aws_sdk_dynamodb.rb
253
+ - lib/instana/instrumentation/aws_sdk_s3.rb
254
+ - lib/instana/instrumentation/aws_sdk_sns.rb
255
+ - lib/instana/instrumentation/aws_sdk_sqs.rb
246
256
  - lib/instana/instrumentation/dalli.rb
247
257
  - lib/instana/instrumentation/excon.rb
248
258
  - lib/instana/instrumentation/graphql.rb
@@ -253,6 +263,7 @@ files:
253
263
  - lib/instana/instrumentation/redis.rb
254
264
  - lib/instana/instrumentation/resque.rb
255
265
  - lib/instana/instrumentation/rest-client.rb
266
+ - lib/instana/instrumentation/shoryuken.rb
256
267
  - lib/instana/instrumentation/sidekiq-client.rb
257
268
  - lib/instana/instrumentation/sidekiq-worker.rb
258
269
  - lib/instana/opentracing/carrier.rb
@@ -294,6 +305,7 @@ files:
294
305
  - test/instrumentation/redis_test.rb
295
306
  - test/instrumentation/resque_test.rb
296
307
  - test/instrumentation/rest_client_test.rb
308
+ - test/instrumentation/shoryuken_test.rb
297
309
  - test/instrumentation/sidekiq-client_test.rb
298
310
  - test/instrumentation/sidekiq-worker_test.rb
299
311
  - test/secrets_test.rb
@@ -365,6 +377,7 @@ test_files:
365
377
  - test/instrumentation/rails_action_view_test.rb
366
378
  - test/instrumentation/rack_test.rb
367
379
  - test/instrumentation/rack_instrumented_request_test.rb
380
+ - test/instrumentation/shoryuken_test.rb
368
381
  - test/instrumentation/rails_active_record_test.rb
369
382
  - test/instrumentation/redis_test.rb
370
383
  - test/instrumentation/dalli_test.rb
data/Dockerfile DELETED
@@ -1,16 +0,0 @@
1
- # For development/testing, you can run this instrumentation
2
- # interactively in a Docker container:
3
- # docker build -t instana/ruby-sensor:1.0
4
- #
5
- # To mount the host ruby-sensor directory in the container:
6
- # docker run -v /host/path/to/ruby-sensor:/ruby-sensor instana/ruby-sensor:1.0 /bin/bash
7
- #
8
- # Once inside the container, you can run `cd /ruby-sensor && bundle install && bundle exec rake console` for a development
9
- # console in the gem.
10
- #
11
- # https://github.com/instana/ruby-sensor#development
12
- #
13
- FROM ruby:2.6
14
- ENV INSTANA_DEBUG=true
15
- RUN gem install bundler
16
- RUN apt update && apt install -y vim