instana 1.193.6 → 1.195.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +16 -2
  3. data/Appraisals +13 -1
  4. data/docker-compose.yml +20 -0
  5. data/gemfiles/aws_30.gemfile +3 -0
  6. data/gemfiles/excon_021.gemfile +18 -0
  7. data/gemfiles/excon_079.gemfile +18 -0
  8. data/gemfiles/shoryuken_50.gemfile +19 -0
  9. data/lib/instana/activators/aws_sdk_s3.rb +20 -0
  10. data/lib/instana/activators/aws_sdk_sns.rb +20 -0
  11. data/lib/instana/activators/aws_sdk_sqs.rb +20 -0
  12. data/lib/instana/activators/excon.rb +1 -1
  13. data/lib/instana/activators/shoryuken.rb +24 -0
  14. data/lib/instana/config.rb +3 -0
  15. data/lib/instana/instrumentation/aws_sdk_dynamodb.rb +21 -2
  16. data/lib/instana/instrumentation/aws_sdk_s3.rb +55 -0
  17. data/lib/instana/instrumentation/aws_sdk_sns.rb +29 -0
  18. data/lib/instana/instrumentation/aws_sdk_sqs.rb +98 -0
  19. data/lib/instana/instrumentation/excon.rb +17 -4
  20. data/lib/instana/instrumentation/instrumented_request.rb +64 -7
  21. data/lib/instana/instrumentation/net-http.rb +9 -2
  22. data/lib/instana/instrumentation/rack.rb +35 -15
  23. data/lib/instana/instrumentation/shoryuken.rb +44 -0
  24. data/lib/instana/secrets.rb +2 -2
  25. data/lib/instana/tracer.rb +14 -11
  26. data/lib/instana/tracing/span.rb +3 -3
  27. data/lib/instana/tracing/span_context.rb +25 -1
  28. data/lib/instana/version.rb +1 -1
  29. data/test/instrumentation/aws_test.rb +130 -2
  30. data/test/instrumentation/excon_test.rb +16 -1
  31. data/test/instrumentation/net_http_test.rb +18 -0
  32. data/test/instrumentation/rack_instrumented_request_test.rb +50 -3
  33. data/test/instrumentation/rack_test.rb +141 -0
  34. data/test/instrumentation/shoryuken_test.rb +47 -0
  35. data/test/tracing/opentracing_test.rb +3 -3
  36. metadata +16 -3
  37. data/Dockerfile +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db77f1675976effa012f80a5d583f271b99e82db24e288a5af82eae4fa423cf1
4
- data.tar.gz: 9fe2b02c6f58355876c91d8954d3039a14b948f67b7a5730319579fb5d405a9f
3
+ metadata.gz: '0068c5ce2a6bf7c75d517562cec424a612a31d8d938fabb7651151f52b3cc5ea'
4
+ data.tar.gz: cffa225ebc37b1a19a6a20d2418af57cd6e559a3635df17b5244bc2d603eaa20
5
5
  SHA512:
6
- metadata.gz: e00009c32acb5e684ee6c2dea9c7a7d4a40133f14ff8ec5929e39e97622b6daf8c5a027ad6cfdf9c3ace7e27f7accb9f1fff25f954e51eab11854ffb7f0f5e9b
7
- data.tar.gz: 7b8f0c486ab5deaa118debcedc1bf43b6164832cde533d52cb99fe8ac44c76ffe9c555101331ed7cff4b7e421fa321898ff3cf195af80d3a4cda4ed2b5c19db9
6
+ metadata.gz: '0991b7a36fe13c5e4b8ebf93647f3a933087c0f92b8e94e2a3b4a8f7c8bcc24712560f4caf550328bc5390a51f59c334483e48b8be4b78236164b2d557608625'
7
+ data.tar.gz: bd5ab3d0ba9f0d80a5b7c86068afb04f3889321fa5a154e43e97f89f577e244e481e0b2208a3fb76ae04452b26bcd32657ca2ea9cd6133230a7e53a8904fc52f
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) && 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
@@ -55,6 +55,9 @@ module Instana
55
55
  # ::Instana.config[:sanitize_sql] = false
56
56
  @config[:sanitize_sql] = true
57
57
 
58
+ # W3 Trace Context Support
59
+ @config[:w3_trace_correlation] = ENV.fetch('INSTANA_W3C_TRACE_CORRELATION', 'true').eql?('true')
60
+
58
61
  @config[:action_controller] = { :enabled => true }
59
62
  @config[:action_view] = { :enabled => true }
60
63
  @config[:active_record] = { :enabled => true }
@@ -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