instana 1.192.1 → 1.193.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +200 -133
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +10 -1145
  5. data/.rubocop_todo.yml +1140 -0
  6. data/Appraisals +103 -0
  7. data/Gemfile +14 -32
  8. data/LICENSE +2 -1
  9. data/Rakefile +19 -39
  10. data/benchmarks/10k-rack-traces.rb +3 -0
  11. data/benchmarks/Gemfile +4 -0
  12. data/benchmarks/id_generation.rb +4 -0
  13. data/benchmarks/opentracing.rb +4 -0
  14. data/benchmarks/rack_vanilla_vs_traced.rb +3 -0
  15. data/benchmarks/stackprof_rack_tracing.rb +3 -0
  16. data/benchmarks/time_processing.rb +4 -0
  17. data/bin/console +8 -4
  18. data/examples/opentracing.rb +4 -0
  19. data/examples/tracing.rb +4 -0
  20. data/extras/license_header.rb +44 -0
  21. data/gemfiles/.bundle/config +1 -2
  22. data/gemfiles/cuba_30.gemfile +18 -0
  23. data/gemfiles/dalli_20.gemfile +18 -0
  24. data/gemfiles/excon_02.gemfile +18 -0
  25. data/gemfiles/graphql_10.gemfile +18 -0
  26. data/gemfiles/grpc_10.gemfile +18 -0
  27. data/gemfiles/net_http_01.gemfile +17 -0
  28. data/gemfiles/rack_16.gemfile +18 -0
  29. data/gemfiles/rack_20.gemfile +18 -0
  30. data/gemfiles/rails_42.gemfile +21 -0
  31. data/gemfiles/rails_50.gemfile +21 -0
  32. data/gemfiles/rails_52.gemfile +21 -0
  33. data/gemfiles/rails_60.gemfile +21 -0
  34. data/gemfiles/redis_40.gemfile +18 -0
  35. data/gemfiles/resque_122.gemfile +19 -0
  36. data/gemfiles/resque_20.gemfile +18 -0
  37. data/gemfiles/rest_client_16.gemfile +18 -0
  38. data/gemfiles/rest_client_20.gemfile +18 -0
  39. data/gemfiles/roda_20.gemfile +18 -0
  40. data/gemfiles/roda_30.gemfile +18 -0
  41. data/gemfiles/sidekiq_42.gemfile +18 -0
  42. data/gemfiles/sidekiq_50.gemfile +18 -0
  43. data/gemfiles/sinatra_14.gemfile +18 -0
  44. data/instana.gemspec +5 -7
  45. data/lib/instana.rb +3 -0
  46. data/lib/instana/activator.rb +44 -0
  47. data/lib/instana/activators/action_cable.rb +24 -0
  48. data/lib/instana/activators/action_controller_api.rb +21 -0
  49. data/lib/instana/activators/action_controller_base.rb +21 -0
  50. data/lib/instana/activators/action_view.rb +21 -0
  51. data/lib/instana/activators/active_record.rb +21 -0
  52. data/lib/instana/activators/cuba.rb +21 -0
  53. data/lib/instana/activators/dalli.rb +23 -0
  54. data/lib/instana/activators/excon.rb +20 -0
  55. data/lib/instana/activators/graphql.rb +22 -0
  56. data/lib/instana/activators/grpc_client.rb +20 -0
  57. data/lib/instana/activators/grpc_server.rb +20 -0
  58. data/lib/instana/activators/net_http.rb +20 -0
  59. data/lib/instana/activators/rack.rb +16 -0
  60. data/lib/instana/activators/rails.rb +18 -0
  61. data/lib/instana/activators/redis.rb +20 -0
  62. data/lib/instana/activators/resque_client.rb +21 -0
  63. data/lib/instana/activators/resque_worker.rb +33 -0
  64. data/lib/instana/activators/rest_client.rb +20 -0
  65. data/lib/instana/activators/roda.rb +21 -0
  66. data/lib/instana/activators/sidekiq_client.rb +24 -0
  67. data/lib/instana/activators/sidekiq_worker.rb +24 -0
  68. data/lib/instana/activators/sinatra.rb +21 -0
  69. data/lib/instana/agent.rb +3 -0
  70. data/lib/instana/agent/helpers.rb +3 -0
  71. data/lib/instana/agent/hooks.rb +3 -0
  72. data/lib/instana/agent/tasks.rb +3 -0
  73. data/lib/instana/base.rb +3 -0
  74. data/lib/instana/collector.rb +3 -0
  75. data/lib/instana/collectors/gc.rb +3 -0
  76. data/lib/instana/collectors/memory.rb +3 -0
  77. data/lib/instana/collectors/thread.rb +3 -0
  78. data/lib/instana/config.rb +3 -0
  79. data/lib/instana/frameworks/cuba.rb +9 -13
  80. data/lib/instana/frameworks/rails.rb +22 -32
  81. data/lib/instana/frameworks/roda.rb +10 -13
  82. data/lib/instana/frameworks/sinatra.rb +4 -8
  83. data/lib/instana/helpers.rb +3 -0
  84. data/lib/instana/instrumentation/action_cable.rb +53 -0
  85. data/lib/instana/instrumentation/action_controller.rb +84 -0
  86. data/lib/instana/instrumentation/action_view.rb +30 -0
  87. data/lib/instana/instrumentation/active_record.rb +50 -0
  88. data/lib/instana/instrumentation/dalli.rb +10 -18
  89. data/lib/instana/instrumentation/excon.rb +54 -57
  90. data/lib/instana/instrumentation/graphql.rb +19 -18
  91. data/lib/instana/instrumentation/grpc.rb +73 -66
  92. data/lib/instana/instrumentation/instrumented_request.rb +6 -1
  93. data/lib/instana/instrumentation/net-http.rb +46 -47
  94. data/lib/instana/instrumentation/rack.rb +4 -0
  95. data/lib/instana/instrumentation/redis.rb +13 -18
  96. data/lib/instana/instrumentation/resque.rb +17 -50
  97. data/lib/instana/instrumentation/rest-client.rb +5 -17
  98. data/lib/instana/instrumentation/sidekiq-client.rb +3 -9
  99. data/lib/instana/instrumentation/sidekiq-worker.rb +3 -9
  100. data/lib/instana/opentracing/carrier.rb +3 -0
  101. data/lib/instana/opentracing/tracer.rb +3 -0
  102. data/lib/instana/rack.rb +4 -0
  103. data/lib/instana/secrets.rb +10 -7
  104. data/lib/instana/setup.rb +6 -1
  105. data/lib/instana/thread_local.rb +3 -0
  106. data/lib/instana/tracer.rb +3 -0
  107. data/lib/instana/tracing/processor.rb +3 -0
  108. data/lib/instana/tracing/span.rb +3 -0
  109. data/lib/instana/tracing/span_context.rb +3 -0
  110. data/lib/instana/util.rb +4 -41
  111. data/lib/instana/version.rb +4 -1
  112. data/lib/oj_check.rb +3 -0
  113. data/lib/opentracing.rb +3 -0
  114. data/test/activator_test.rb +30 -0
  115. data/test/agent/agent_test.rb +3 -0
  116. data/test/benchmarks/bench_id_generation.rb +3 -0
  117. data/test/benchmarks/bench_opentracing.rb +3 -0
  118. data/test/config_test.rb +3 -0
  119. data/test/frameworks/cuba_test.rb +41 -40
  120. data/test/frameworks/roda_test.rb +43 -41
  121. data/test/frameworks/sinatra_test.rb +64 -64
  122. data/test/instana_test.rb +3 -0
  123. data/test/instrumentation/dalli_test.rb +3 -0
  124. data/test/instrumentation/excon_test.rb +4 -0
  125. data/test/instrumentation/graphql_test.rb +3 -0
  126. data/test/instrumentation/grpc_test.rb +5 -1
  127. data/test/instrumentation/{net-http_test.rb → net_http_test.rb} +4 -0
  128. data/test/instrumentation/{instrumented_request_test.rb → rack_instrumented_request_test.rb} +4 -1
  129. data/test/{frameworks → instrumentation}/rack_test.rb +3 -1
  130. data/test/instrumentation/rails_action_cable_test.rb +131 -0
  131. data/test/{frameworks/rails/actioncontroller_test.rb → instrumentation/rails_action_controller_test.rb} +40 -21
  132. data/test/instrumentation/rails_action_view_test.rb +151 -0
  133. data/test/instrumentation/rails_active_record_test.rb +122 -0
  134. data/test/instrumentation/redis_test.rb +3 -0
  135. data/test/instrumentation/resque_test.rb +6 -11
  136. data/test/instrumentation/{rest-client_test.rb → rest_client_test.rb} +9 -0
  137. data/test/instrumentation/sidekiq-client_test.rb +4 -0
  138. data/test/instrumentation/sidekiq-worker_test.rb +4 -0
  139. data/test/secrets_test.rb +3 -0
  140. data/test/support/apps/active_record/active_record.rb +24 -0
  141. data/test/{servers/grpc_50051.rb → support/apps/grpc/boot.rb} +4 -1
  142. data/test/{apps → support/apps/grpc}/grpc_server.rb +3 -0
  143. data/test/{servers/rackapp_6511.rb → support/apps/http_endpoint/boot.rb} +3 -0
  144. data/test/{servers/rails_3205.rb → support/apps/rails/boot.rb} +10 -13
  145. data/test/{models → support/apps/rails/models}/block.rb +4 -1
  146. data/test/{models → support/apps/rails/models}/block6.rb +3 -0
  147. data/test/support/apps/resque/boot.rb +5 -0
  148. data/test/{jobs → support/apps/resque/jobs}/resque_error_job.rb +3 -0
  149. data/test/{jobs → support/apps/resque/jobs}/resque_fast_job.rb +3 -0
  150. data/test/support/apps/sidekiq/boot.rb +25 -0
  151. data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_1.rb +3 -0
  152. data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_2.rb +3 -0
  153. data/test/{servers → support/apps}/sidekiq/worker.rb +5 -2
  154. data/test/support/helpers.rb +97 -0
  155. data/test/test_helper.rb +27 -144
  156. data/test/tracing/custom_test.rb +3 -0
  157. data/test/tracing/id_management_test.rb +4 -0
  158. data/test/tracing/opentracing_test.rb +3 -0
  159. data/test/tracing/tracer_async_test.rb +3 -0
  160. data/test/tracing/tracer_test.rb +3 -0
  161. metadata +105 -96
  162. data/gemfiles/libraries.gemfile +0 -73
  163. data/gemfiles/rails32.gemfile +0 -51
  164. data/gemfiles/rails42.gemfile +0 -50
  165. data/gemfiles/rails50.gemfile +0 -52
  166. data/gemfiles/rails52.gemfile +0 -52
  167. data/gemfiles/rails60.gemfile +0 -72
  168. data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +0 -58
  169. data/lib/instana/frameworks/instrumentation/action_controller.rb +0 -194
  170. data/lib/instana/frameworks/instrumentation/action_view.rb +0 -43
  171. data/lib/instana/frameworks/instrumentation/active_record.rb +0 -27
  172. data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +0 -87
  173. data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +0 -62
  174. data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +0 -103
  175. data/lib/instana/instrumentation.rb +0 -25
  176. data/lib/instana/test.rb +0 -43
  177. data/test/apps/cuba.rb +0 -19
  178. data/test/apps/roda.rb +0 -13
  179. data/test/apps/sinatra.rb +0 -9
  180. data/test/frameworks/rails/actionview3_test.rb +0 -210
  181. data/test/frameworks/rails/actionview4_test.rb +0 -208
  182. data/test/frameworks/rails/actionview5_test.rb +0 -221
  183. data/test/frameworks/rails/activerecord_test.rb +0 -279
  184. data/test/servers/helpers/sidekiq_worker_initializer.rb +0 -27
@@ -1,6 +1,11 @@
1
1
  # Note: We really only need "cgi/util" here but Ruby 2.4.1 has an issue:
2
2
  # https://bugs.ruby-lang.org/issues/13539
3
- require "cgi"
3
+
4
+ # (c) Copyright IBM Corp. 2021
5
+ # (c) Copyright Instana Inc. 2021
6
+
7
+ require 'cgi'
8
+ require 'rack/request'
4
9
 
5
10
  module Instana
6
11
  class InstrumentedRequest < Rack::Request
@@ -1,61 +1,60 @@
1
- require 'net/http'
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
2
3
 
3
- if defined?(::Net::HTTP) && ::Instana.config[:nethttp][:enabled]
4
- Net::HTTP.class_eval {
4
+ require 'net/http'
5
5
 
6
- def request_with_instana(*args, &block)
7
- if !Instana.tracer.tracing? || !started?
8
- do_skip = true
9
- return request_without_instana(*args, &block)
10
- end
6
+ module Instana
7
+ module Instrumentation
8
+ module NetHTTPInstrumentation
9
+ def request(*args, &block)
10
+ if !Instana.tracer.tracing? || !started?
11
+ do_skip = true
12
+ return super(*args, &block)
13
+ end
11
14
 
12
- ::Instana.tracer.log_entry(:'net-http')
15
+ ::Instana.tracer.log_entry(:'net-http')
13
16
 
14
- # Send out the tracing context with the request
15
- request = args[0]
17
+ # Send out the tracing context with the request
18
+ request = args[0]
16
19
 
17
- # Set request headers; encode IDs as hexadecimal strings
18
- t_context = ::Instana.tracer.context
19
- request['X-Instana-T'] = t_context.trace_id_header
20
- request['X-Instana-S'] = t_context.span_id_header
20
+ # Set request headers; encode IDs as hexadecimal strings
21
+ t_context = ::Instana.tracer.context
22
+ request['X-Instana-T'] = t_context.trace_id_header
23
+ request['X-Instana-S'] = t_context.span_id_header
21
24
 
22
- # Collect up KV info now in case any exception is raised
23
- kv_payload = { :http => {} }
24
- kv_payload[:http][:method] = request.method
25
+ # Collect up KV info now in case any exception is raised
26
+ kv_payload = { :http => {} }
27
+ kv_payload[:http][:method] = request.method
25
28
 
26
- if request.uri
27
- kv_payload[:http][:url] = request.uri.to_s
28
- else
29
- if use_ssl?
30
- kv_payload[:http][:url] = "https://#{@address}:#{@port}#{request.path}"
29
+ if request.uri
30
+ kv_payload[:http][:url] = request.uri.to_s
31
31
  else
32
- kv_payload[:http][:url] = "http://#{@address}:#{@port}#{request.path}"
32
+ if use_ssl?
33
+ kv_payload[:http][:url] = "https://#{@address}:#{@port}#{request.path}"
34
+ else
35
+ kv_payload[:http][:url] = "http://#{@address}:#{@port}#{request.path}"
36
+ end
33
37
  end
34
- end
35
-
36
- kv_payload[:http][:url] = ::Instana.secrets.remove_from_query(kv_payload[:http][:url])
37
38
 
38
- # The core call
39
- response = request_without_instana(*args, &block)
39
+ kv_payload[:http][:url] = ::Instana.secrets.remove_from_query(kv_payload[:http][:url])
40
40
 
41
- kv_payload[:http][:status] = response.code
42
- if response.code.to_i.between?(500, 511)
43
- # Because of the 5xx response, we flag this span as errored but
44
- # without a backtrace (no exception)
45
- ::Instana.tracer.log_error(nil)
46
- end
41
+ # The core call
42
+ response = super(*args, &block)
47
43
 
48
- response
49
- rescue => e
50
- ::Instana.tracer.log_error(e)
51
- raise
52
- ensure
53
- ::Instana.tracer.log_exit(:'net-http', kv_payload) unless do_skip
54
- end
55
-
56
- ::Instana.logger.debug "Instrumenting Net::HTTP"
44
+ kv_payload[:http][:status] = response.code
45
+ if response.code.to_i.between?(500, 511)
46
+ # Because of the 5xx response, we flag this span as errored but
47
+ # without a backtrace (no exception)
48
+ ::Instana.tracer.log_error(nil)
49
+ end
57
50
 
58
- alias request_without_instana request
59
- alias request request_with_instana
60
- }
51
+ response
52
+ rescue => e
53
+ ::Instana.tracer.log_error(e)
54
+ raise
55
+ ensure
56
+ ::Instana.tracer.log_exit(:'net-http', kv_payload) unless do_skip
57
+ end
58
+ end
59
+ end
61
60
  end
@@ -1,3 +1,7 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
4
+ require 'rack'
1
5
  require 'instana/instrumentation/instrumented_request'
2
6
 
3
7
  module Instana
@@ -1,11 +1,14 @@
1
- if defined?(::Redis) && ::Instana.config[:redis][:enabled]
2
- ::Redis::Client.class_eval do
3
- def call_with_instana(*args, &block)
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
4
+ module Instana
5
+ module RedisInstrumentation
6
+ def call(*args, &block)
4
7
  kv_payload = { redis: {} }
5
8
  dnt_spans = [:redis, :'resque-client', :'sidekiq-client']
6
9
 
7
- if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name)
8
- return call_without_instana(*args, &block)
10
+ if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name) || !Instana.config[:redis][:enabled]
11
+ return super(*args, &block)
9
12
  end
10
13
 
11
14
  begin
@@ -19,7 +22,7 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
19
22
  nil
20
23
  end
21
24
 
22
- call_without_instana(*args, &block)
25
+ super(*args, &block)
23
26
  rescue => e
24
27
  ::Instana.tracer.log_info({ redis: {error: true} })
25
28
  ::Instana.tracer.log_error(e)
@@ -29,17 +32,12 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
29
32
  end
30
33
  end
31
34
 
32
- ::Instana.logger.debug "Instrumenting Redis"
33
-
34
- alias call_without_instana call
35
- alias call call_with_instana
36
-
37
- def call_pipeline_with_instana(*args, &block)
35
+ def call_pipeline(*args, &block)
38
36
  kv_payload = { redis: {} }
39
37
  dnt_spans = [:redis, :'resque-client', :'sidekiq-client']
40
38
 
41
- if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name)
42
- return call_pipeline_without_instana(*args, &block)
39
+ if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name) || !Instana.config[:redis][:enabled]
40
+ return super(*args, &block)
43
41
  end
44
42
 
45
43
  begin
@@ -54,7 +52,7 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
54
52
  nil
55
53
  end
56
54
 
57
- call_pipeline_without_instana(*args, &block)
55
+ super(*args, &block)
58
56
  rescue => e
59
57
  ::Instana.tracer.log_info({ redis: {error: true} })
60
58
  ::Instana.tracer.log_error(e)
@@ -63,8 +61,5 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
63
61
  ::Instana.tracer.log_exit(:redis, kv_payload)
64
62
  end
65
63
  end
66
-
67
- alias call_pipeline_without_instana call_pipeline
68
- alias call_pipeline call_pipeline_with_instana
69
64
  end
70
65
  end
@@ -1,13 +1,13 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2018
3
+
1
4
  require 'socket'
2
5
 
3
6
  module Instana
4
7
  module Instrumentation
5
8
  module ResqueClient
6
- def self.included(klass)
9
+ def self.prepended(klass)
7
10
  klass.send :extend, ::Resque
8
- ::Instana::Util.method_alias(klass, :enqueue)
9
- ::Instana::Util.method_alias(klass, :enqueue_to)
10
- ::Instana::Util.method_alias(klass, :dequeue)
11
11
  end
12
12
 
13
13
  def collect_kvs(op, klass, args)
@@ -23,50 +23,46 @@ module Instana
23
23
  { :'resque-client' => kvs }
24
24
  end
25
25
 
26
- def enqueue_with_instana(klass, *args)
26
+ def enqueue(klass, *args)
27
27
  if Instana.tracer.tracing?
28
28
  kvs = collect_kvs(:enqueue, klass, args)
29
29
 
30
30
  Instana.tracer.trace(:'resque-client', kvs) do
31
- enqueue_without_instana(klass, *args)
31
+ super(klass, *args)
32
32
  end
33
33
  else
34
- enqueue_without_instana(klass, *args)
34
+ super(klass, *args)
35
35
  end
36
36
  end
37
37
 
38
- def enqueue_to_with_instana(queue, klass, *args)
38
+ def enqueue_to(queue, klass, *args)
39
39
  if Instana.tracer.tracing? && !Instana.tracer.tracing_span?(:'resque-client')
40
40
  kvs = collect_kvs(:enqueue_to, klass, args)
41
41
  kvs[:Queue] = queue.to_s if queue
42
42
 
43
43
  Instana.tracer.trace(:'resque-client', kvs) do
44
- enqueue_to_without_instana(queue, klass, *args)
44
+ super(queue, klass, *args)
45
45
  end
46
46
  else
47
- enqueue_to_without_instana(queue, klass, *args)
47
+ super(queue, klass, *args)
48
48
  end
49
49
  end
50
50
 
51
- def dequeue_with_instana(klass, *args)
51
+ def dequeue(klass, *args)
52
52
  if Instana.tracer.tracing?
53
53
  kvs = collect_kvs(:dequeue, klass, args)
54
54
 
55
55
  Instana.tracer.trace(:'resque-client', kvs) do
56
- dequeue_without_instana(klass, *args)
56
+ super(klass, *args)
57
57
  end
58
58
  else
59
- dequeue_without_instana(klass, *args)
59
+ super(klass, *args)
60
60
  end
61
61
  end
62
62
  end
63
63
 
64
64
  module ResqueWorker
65
- def self.included(klass)
66
- ::Instana::Util.method_alias(klass, :perform)
67
- end
68
-
69
- def perform_with_instana(job)
65
+ def perform(job)
70
66
  kvs = {}
71
67
  kvs[:'resque-worker'] = {}
72
68
 
@@ -81,17 +77,13 @@ module Instana
81
77
  end
82
78
 
83
79
  Instana.tracer.start_or_continue_trace(:'resque-worker', kvs) do
84
- perform_without_instana(job)
80
+ super(job)
85
81
  end
86
82
  end
87
83
  end
88
84
 
89
85
  module ResqueJob
90
- def self.included(klass)
91
- ::Instana::Util.method_alias(klass, :fail)
92
- end
93
-
94
- def fail_with_instana(exception)
86
+ def fail(exception)
95
87
  if Instana.tracer.tracing?
96
88
  ::Instana.tracer.log_info(:'resque-worker' => { :error => "#{exception.class}: #{exception}"})
97
89
  ::Instana.tracer.log_error(exception)
@@ -99,33 +91,8 @@ module Instana
99
91
  rescue Exception => e
100
92
  ::Instana.logger.debug { "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" } if Instana::Config[:verbose]
101
93
  ensure
102
- fail_without_instana(exception)
94
+ super(exception)
103
95
  end
104
96
  end
105
97
  end
106
98
  end
107
-
108
- if defined?(::Resque) && RUBY_VERSION >= '1.9.3'
109
-
110
- if ::Instana.config[:'resque-client'][:enabled]
111
- ::Instana.logger.debug 'Instrumenting Resque Client'
112
- ::Instana::Util.send_include(::Resque, ::Instana::Instrumentation::ResqueClient)
113
- end
114
-
115
- if ::Instana.config[:'resque-worker'][:enabled]
116
- ::Instana.logger.debug 'Instrumenting Resque Worker'
117
-
118
- ::Instana::Util.send_include(::Resque::Worker, ::Instana::Instrumentation::ResqueWorker)
119
- ::Instana::Util.send_include(::Resque::Job, ::Instana::Instrumentation::ResqueJob)
120
-
121
- ::Resque.before_fork do |job|
122
- ::Instana.agent.before_resque_fork
123
- end
124
- ::Resque.after_fork do |job|
125
- ::Instana.agent.after_resque_fork
126
- end
127
-
128
- # Set this so we assure that any remaining collected traces are reported at_exit
129
- ENV['RUN_AT_EXIT_HOOKS'] = "1"
130
- end
131
- end
@@ -1,34 +1,22 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  module Instana
2
5
  module Instrumentation
3
6
  module RestClientRequest
4
- def self.included(klass)
5
- if klass.method_defined?(:execute)
6
- klass.class_eval do
7
- alias execute_without_instana execute
8
- alias execute execute_with_instana
9
- end
10
- end
11
- end
12
-
13
- def execute_with_instana & block
7
+ def execute(&block)
14
8
  # Since RestClient uses net/http under the covers, we just
15
9
  # provide span visibility here. HTTP related KVs are reported
16
10
  # in the Net::HTTP instrumentation
17
11
  ::Instana.tracer.log_entry(:'rest-client')
18
12
 
19
- execute_without_instana(&block)
13
+ super(&block)
20
14
  rescue => e
21
15
  ::Instana.tracer.log_error(e)
22
16
  raise
23
17
  ensure
24
18
  ::Instana.tracer.log_exit(:'rest-client')
25
19
  end
26
-
27
20
  end
28
21
  end
29
22
  end
30
-
31
- if defined?(::RestClient::Request) && ::Instana.config[:'rest-client'][:enabled]
32
- ::Instana.logger.debug "Instrumenting RestClient"
33
- ::RestClient::Request.send(:include, ::Instana::Instrumentation::RestClientRequest)
34
- end
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  module Instana
2
5
  module Instrumentation
3
6
  class SidekiqClient
@@ -34,12 +37,3 @@ module Instana
34
37
  end
35
38
  end
36
39
  end
37
-
38
- if defined?(::Sidekiq) && ::Instana.config[:'sidekiq-client'][:enabled]
39
- ::Sidekiq.configure_client do |cfg|
40
- cfg.client_middleware do |chain|
41
- ::Instana.logger.debug "Instrumenting Sidekiq client"
42
- chain.add ::Instana::Instrumentation::SidekiqClient
43
- end
44
- end
45
- end
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  module Instana
2
5
  module Instrumentation
3
6
  class SidekiqWorker
@@ -43,12 +46,3 @@ module Instana
43
46
  end
44
47
  end
45
48
  end
46
-
47
- if defined?(::Sidekiq) && ::Instana.config[:'sidekiq-worker'][:enabled]
48
- ::Sidekiq.configure_server do |cfg|
49
- cfg.server_middleware do |chain|
50
- ::Instana.logger.debug "Instrumenting Sidekiq worker"
51
- chain.add ::Instana::Instrumentation::SidekiqWorker
52
- end
53
- end
54
- end
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  module OpenTracing
2
5
  class Carrier < Hash
3
6
  end
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  module OpenTracing
2
5
  class << self
3
6
  # Text format for #inject and #extract
data/lib/instana/rack.rb CHANGED
@@ -7,4 +7,8 @@
7
7
  # require 'instana/rack'
8
8
  # config.middleware.use ::Instana::Rack
9
9
  #
10
+
11
+ # (c) Copyright IBM Corp. 2021
12
+ # (c) Copyright Instana Inc. 2016
13
+
10
14
  require 'instana/instrumentation/rack'
@@ -1,26 +1,29 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
1
4
  require 'uri'
2
5
  require 'cgi'
3
6
 
4
7
  module Instana
5
- class Secrets
8
+ class Secrets
6
9
  def remove_from_query(str, secret_values = Instana.agent.secret_values)
7
10
  return str unless secret_values
8
-
11
+
9
12
  url = URI(str)
10
- params = CGI.parse(url.query)
11
-
13
+ params = CGI.parse(url.query || '')
14
+
12
15
  redacted = params.map do |k, v|
13
16
  needs_redaction = secret_values['list']
14
17
  .any? { |t| matcher(secret_values['matcher']).(t,k) }
15
18
  [k, needs_redaction ? '<redacted>' : v]
16
19
  end
17
-
20
+
18
21
  url.query = URI.encode_www_form(redacted)
19
22
  CGI.unescape(url.to_s)
20
23
  end
21
-
24
+
22
25
  private
23
-
26
+
24
27
  def matcher(name)
25
28
  case name
26
29
  when 'equals-ignore-case'