instana 1.13.0 → 1.193.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +200 -133
  3. data/.editorconfig +10 -0
  4. data/.gitignore +3 -0
  5. data/.rubocop.yml +5 -1147
  6. data/.rubocop_todo.yml +1140 -0
  7. data/Appraisals +100 -0
  8. data/Gemfile +11 -32
  9. data/Rakefile +16 -39
  10. data/bin/console +5 -4
  11. data/gemfiles/.bundle/config +1 -2
  12. data/gemfiles/cuba_30.gemfile +15 -0
  13. data/gemfiles/dalli_20.gemfile +15 -0
  14. data/gemfiles/excon_02.gemfile +15 -0
  15. data/gemfiles/graphql_10.gemfile +15 -0
  16. data/gemfiles/grpc_10.gemfile +15 -0
  17. data/gemfiles/net_http_01.gemfile +14 -0
  18. data/gemfiles/rack_16.gemfile +15 -0
  19. data/gemfiles/rack_20.gemfile +15 -0
  20. data/gemfiles/rails_42.gemfile +18 -0
  21. data/gemfiles/rails_50.gemfile +18 -0
  22. data/gemfiles/rails_52.gemfile +18 -0
  23. data/gemfiles/rails_60.gemfile +18 -0
  24. data/gemfiles/redis_40.gemfile +15 -0
  25. data/gemfiles/resque_122.gemfile +16 -0
  26. data/gemfiles/resque_20.gemfile +15 -0
  27. data/gemfiles/rest_client_16.gemfile +15 -0
  28. data/gemfiles/rest_client_20.gemfile +15 -0
  29. data/gemfiles/roda_20.gemfile +15 -0
  30. data/gemfiles/roda_30.gemfile +15 -0
  31. data/gemfiles/sidekiq_42.gemfile +15 -0
  32. data/gemfiles/sidekiq_50.gemfile +15 -0
  33. data/gemfiles/sinatra_14.gemfile +15 -0
  34. data/instana.gemspec +1 -7
  35. data/lib/instana/activator.rb +41 -0
  36. data/lib/instana/activators/action_controller_api.rb +18 -0
  37. data/lib/instana/activators/action_controller_base.rb +18 -0
  38. data/lib/instana/activators/action_view.rb +18 -0
  39. data/lib/instana/activators/active_record.rb +18 -0
  40. data/lib/instana/activators/cuba.rb +18 -0
  41. data/lib/instana/activators/dalli.rb +20 -0
  42. data/lib/instana/activators/excon.rb +17 -0
  43. data/lib/instana/activators/graphql.rb +19 -0
  44. data/lib/instana/activators/grpc_client.rb +17 -0
  45. data/lib/instana/activators/grpc_server.rb +17 -0
  46. data/lib/instana/activators/net_http.rb +17 -0
  47. data/lib/instana/activators/rack.rb +13 -0
  48. data/lib/instana/activators/rails.rb +15 -0
  49. data/lib/instana/activators/redis.rb +17 -0
  50. data/lib/instana/activators/resque_client.rb +18 -0
  51. data/lib/instana/activators/resque_worker.rb +30 -0
  52. data/lib/instana/activators/rest_client.rb +17 -0
  53. data/lib/instana/activators/roda.rb +18 -0
  54. data/lib/instana/activators/sidekiq_client.rb +21 -0
  55. data/lib/instana/activators/sidekiq_worker.rb +21 -0
  56. data/lib/instana/activators/sinatra.rb +18 -0
  57. data/lib/instana/config.rb +11 -0
  58. data/lib/instana/frameworks/cuba.rb +6 -13
  59. data/lib/instana/frameworks/rails.rb +20 -33
  60. data/lib/instana/frameworks/roda.rb +7 -13
  61. data/lib/instana/frameworks/sinatra.rb +1 -8
  62. data/lib/instana/instrumentation/action_controller.rb +81 -0
  63. data/lib/instana/instrumentation/action_view.rb +27 -0
  64. data/lib/instana/instrumentation/active_record.rb +47 -0
  65. data/lib/instana/instrumentation/dalli.rb +7 -18
  66. data/lib/instana/instrumentation/excon.rb +51 -57
  67. data/lib/instana/instrumentation/graphql.rb +75 -0
  68. data/lib/instana/instrumentation/grpc.rb +70 -66
  69. data/lib/instana/instrumentation/instrumented_request.rb +69 -0
  70. data/lib/instana/instrumentation/net-http.rb +43 -47
  71. data/lib/instana/instrumentation/rack.rb +14 -53
  72. data/lib/instana/instrumentation/redis.rb +10 -18
  73. data/lib/instana/instrumentation/resque.rb +14 -50
  74. data/lib/instana/instrumentation/rest-client.rb +2 -17
  75. data/lib/instana/instrumentation/sidekiq-client.rb +0 -9
  76. data/lib/instana/instrumentation/sidekiq-worker.rb +0 -9
  77. data/lib/instana/secrets.rb +7 -7
  78. data/lib/instana/setup.rb +3 -1
  79. data/lib/instana/tracer.rb +6 -0
  80. data/lib/instana/tracing/span.rb +14 -10
  81. data/lib/instana/util.rb +15 -69
  82. data/lib/instana/version.rb +1 -1
  83. data/test/activator_test.rb +27 -0
  84. data/test/frameworks/cuba_test.rb +38 -40
  85. data/test/frameworks/roda_test.rb +39 -41
  86. data/test/frameworks/sinatra_test.rb +61 -64
  87. data/test/instrumentation/excon_test.rb +1 -2
  88. data/test/instrumentation/graphql_test.rb +116 -0
  89. data/test/instrumentation/grpc_test.rb +2 -1
  90. data/test/instrumentation/{net-http_test.rb → net_http_test.rb} +1 -0
  91. data/test/instrumentation/rack_instrumented_request_test.rb +84 -0
  92. data/test/{frameworks → instrumentation}/rack_test.rb +32 -20
  93. data/test/{frameworks/rails/actioncontroller_test.rb → instrumentation/rails_action_controller_test.rb} +37 -21
  94. data/test/instrumentation/rails_action_view_test.rb +138 -0
  95. data/test/instrumentation/rails_active_record_test.rb +121 -0
  96. data/test/instrumentation/redis_test.rb +10 -0
  97. data/test/instrumentation/resque_test.rb +3 -11
  98. data/test/instrumentation/{rest-client_test.rb → rest_client_test.rb} +6 -0
  99. data/test/instrumentation/sidekiq-client_test.rb +1 -0
  100. data/test/instrumentation/sidekiq-worker_test.rb +1 -0
  101. data/test/support/apps/active_record/active_record.rb +21 -0
  102. data/test/{servers/grpc_50051.rb → support/apps/grpc/boot.rb} +1 -1
  103. data/test/{apps → support/apps/grpc}/grpc_server.rb +0 -0
  104. data/test/{servers/rackapp_6511.rb → support/apps/http_endpoint/boot.rb} +0 -0
  105. data/test/{servers/rails_3205.rb → support/apps/rails/boot.rb} +8 -14
  106. data/test/{models → support/apps/rails/models}/block.rb +1 -1
  107. data/test/{models → support/apps/rails/models}/block6.rb +0 -0
  108. data/test/support/apps/resque/boot.rb +2 -0
  109. data/test/{jobs → support/apps/resque/jobs}/resque_error_job.rb +0 -0
  110. data/test/{jobs → support/apps/resque/jobs}/resque_fast_job.rb +0 -0
  111. data/test/support/apps/sidekiq/boot.rb +21 -0
  112. data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_1.rb +0 -0
  113. data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_2.rb +0 -0
  114. data/test/{servers → support/apps}/sidekiq/worker.rb +2 -2
  115. data/test/support/helpers.rb +94 -0
  116. data/test/test_helper.rb +24 -144
  117. data/test/tracing/id_management_test.rb +4 -66
  118. metadata +106 -95
  119. data/gemfiles/libraries.gemfile +0 -71
  120. data/gemfiles/rails32.gemfile +0 -51
  121. data/gemfiles/rails42.gemfile +0 -50
  122. data/gemfiles/rails50.gemfile +0 -52
  123. data/gemfiles/rails52.gemfile +0 -52
  124. data/gemfiles/rails60.gemfile +0 -72
  125. data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +0 -58
  126. data/lib/instana/frameworks/instrumentation/action_controller.rb +0 -194
  127. data/lib/instana/frameworks/instrumentation/action_view.rb +0 -43
  128. data/lib/instana/frameworks/instrumentation/active_record.rb +0 -27
  129. data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +0 -81
  130. data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +0 -56
  131. data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +0 -85
  132. data/lib/instana/instrumentation.rb +0 -25
  133. data/lib/instana/test.rb +0 -43
  134. data/test/apps/cuba.rb +0 -19
  135. data/test/apps/roda.rb +0 -13
  136. data/test/apps/sinatra.rb +0 -9
  137. data/test/frameworks/rails/actionview3_test.rb +0 -210
  138. data/test/frameworks/rails/actionview4_test.rb +0 -208
  139. data/test/frameworks/rails/actionview5_test.rb +0 -221
  140. data/test/frameworks/rails/activerecord_test.rb +0 -227
  141. data/test/servers/helpers/sidekiq_worker_initializer.rb +0 -27
@@ -0,0 +1,69 @@
1
+ # Note: We really only need "cgi/util" here but Ruby 2.4.1 has an issue:
2
+ # https://bugs.ruby-lang.org/issues/13539
3
+ require 'cgi'
4
+ require 'rack/request'
5
+
6
+ module Instana
7
+ class InstrumentedRequest < Rack::Request
8
+ def skip_trace?
9
+ # Honor X-Instana-L
10
+ @env.has_key?('HTTP_X_INSTANA_L') && @env['HTTP_X_INSTANA_L'].start_with?('0')
11
+ end
12
+
13
+ def incoming_context
14
+ context = {}
15
+
16
+ if @env['HTTP_X_INSTANA_T']
17
+ context[:trace_id] = ::Instana::Util.header_to_id(@env['HTTP_X_INSTANA_T'])
18
+ context[:span_id] = ::Instana::Util.header_to_id(@env['HTTP_X_INSTANA_S']) if @env['HTTP_X_INSTANA_S']
19
+ context[:level] = @env['HTTP_X_INSTANA_L'][0] if @env['HTTP_X_INSTANA_L']
20
+ end
21
+
22
+ context
23
+ end
24
+
25
+ def extra_header_tags
26
+ return nil unless ::Instana.agent.extra_headers
27
+ headers = {}
28
+
29
+ ::Instana.agent.extra_headers.each do |custom_header|
30
+ # Headers are available in this format: HTTP_X_CAPTURE_THIS
31
+ rack_header = 'HTTP_' + custom_header.upcase
32
+ rack_header.tr!('-', '_')
33
+
34
+ headers[custom_header.to_sym] = @env[rack_header] if @env.has_key?(rack_header)
35
+ end
36
+
37
+ headers
38
+ end
39
+
40
+ def request_tags
41
+ {
42
+ method: request_method,
43
+ url: CGI.unescape(path_info),
44
+ host: host_with_port,
45
+ header: extra_header_tags
46
+ }.compact
47
+ end
48
+
49
+ def correlation_data
50
+ @correlation_data ||= parse_correlation_data
51
+ end
52
+
53
+ private
54
+
55
+ def parse_correlation_data
56
+ return {} unless @env.has_key?('HTTP_X_INSTANA_L')
57
+ _level, *tokens = @env['HTTP_X_INSTANA_L'].split(/[,=;]/)
58
+ data = tokens
59
+ .map { |t| t.strip }
60
+ .each_slice(2)
61
+ .select { |a| a.length == 2 }.to_h
62
+
63
+ {
64
+ type: data['correlationType'],
65
+ id: data['correlationId']
66
+ }.compact
67
+ end
68
+ end
69
+ end
@@ -1,61 +1,57 @@
1
1
  require 'net/http'
2
2
 
3
- if defined?(::Net::HTTP) && ::Instana.config[:nethttp][:enabled]
4
- Net::HTTP.class_eval {
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
3
+ module Instana
4
+ module Instrumentation
5
+ module NetHTTPInstrumentation
6
+ def request(*args, &block)
7
+ if !Instana.tracer.tracing? || !started?
8
+ do_skip = true
9
+ return super(*args, &block)
10
+ end
11
11
 
12
- ::Instana.tracer.log_entry(:'net-http')
12
+ ::Instana.tracer.log_entry(:'net-http')
13
13
 
14
- # Send out the tracing context with the request
15
- request = args[0]
14
+ # Send out the tracing context with the request
15
+ request = args[0]
16
16
 
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
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
21
21
 
22
- # Collect up KV info now in case any exception is raised
23
- kv_payload = { :http => {} }
24
- kv_payload[:http][:method] = request.method
22
+ # Collect up KV info now in case any exception is raised
23
+ kv_payload = { :http => {} }
24
+ kv_payload[:http][:method] = request.method
25
25
 
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}"
26
+ if request.uri
27
+ kv_payload[:http][:url] = request.uri.to_s
31
28
  else
32
- kv_payload[:http][:url] = "http://#{@address}:#{@port}#{request.path}"
29
+ if use_ssl?
30
+ kv_payload[:http][:url] = "https://#{@address}:#{@port}#{request.path}"
31
+ else
32
+ kv_payload[:http][:url] = "http://#{@address}:#{@port}#{request.path}"
33
+ end
33
34
  end
34
- end
35
-
36
- kv_payload[:http][:url] = ::Instana.secrets.remove_from_query(kv_payload[:http][:url])
37
-
38
- # The core call
39
- response = request_without_instana(*args, &block)
40
35
 
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
36
+ kv_payload[:http][:url] = ::Instana.secrets.remove_from_query(kv_payload[:http][:url])
47
37
 
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
38
+ # The core call
39
+ response = super(*args, &block)
55
40
 
56
- ::Instana.logger.debug "Instrumenting Net::HTTP"
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
57
47
 
58
- alias request_without_instana request
59
- alias request request_with_instana
60
- }
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
+ end
56
+ end
61
57
  end
@@ -1,6 +1,5 @@
1
- # Note: We really only need "cgi/util" here but Ruby 2.4.1 has an issue:
2
- # https://bugs.ruby-lang.org/issues/13539
3
- require "cgi"
1
+ require 'rack'
2
+ require 'instana/instrumentation/instrumented_request'
4
3
 
5
4
  module Instana
6
5
  class Rack
@@ -8,59 +7,21 @@ module Instana
8
7
  @app = app
9
8
  end
10
9
 
11
- def collect_kvs(env)
12
- kvs = {}
13
- kvs[:http] = {}
14
- kvs[:http][:method] = env['REQUEST_METHOD']
15
- kvs[:http][:url] = ::CGI.unescape(env['PATH_INFO'])
16
-
17
- if env.key?('HTTP_HOST')
18
- kvs[:http][:host] = env['HTTP_HOST']
19
- elsif env.key?('SERVER_NAME')
20
- kvs[:http][:host] = env['SERVER_NAME']
21
- end
22
-
23
- if ENV.key?('INSTANA_SERVICE_NAME')
24
- kvs[:service] = ENV['INSTANA_SERVICE_NAME']
25
- end
26
-
27
- if ::Instana.agent.extra_headers
28
- ::Instana.agent.extra_headers.each { |custom_header|
29
- # Headers are available in this format: HTTP_X_CAPTURE_THIS
30
- rack_header = 'HTTP_' + custom_header.upcase
31
- rack_header.tr!('-', '_')
32
-
33
- if env.key?(rack_header)
34
- unless kvs[:http].key?(:header)
35
- kvs[:http][:header] = {}
36
- end
37
- kvs[:http][:header][custom_header.to_sym] = env[rack_header]
38
- end
39
- }
40
- end
41
- return kvs
42
- end
43
-
44
10
  def call(env)
45
- # Check incoming context
46
- incoming_context = {}
47
- if env.key?('HTTP_X_INSTANA_T')
48
- incoming_context[:trace_id] = ::Instana::Util.header_to_id(env['HTTP_X_INSTANA_T'])
49
- incoming_context[:span_id] = ::Instana::Util.header_to_id(env['HTTP_X_INSTANA_S']) if env.key?('HTTP_X_INSTANA_S')
50
- incoming_context[:level] = env['HTTP_X_INSTANA_L'] if env.key?('HTTP_X_INSTANA_L')
51
-
52
- # Honor X-Instana-L
53
- if incoming_context[:level] and incoming_context[:level].length > 0
54
- if incoming_context[:level][0] == "0"
55
- return @app.call(env)
56
- end
57
- end
11
+ req = InstrumentedRequest.new(env)
12
+ return @app.call(env) if req.skip_trace?
13
+ kvs = {
14
+ http: req.request_tags,
15
+ service: ENV['INSTANA_SERVICE_NAME']
16
+ }.compact
17
+
18
+ current_span = ::Instana.tracer.log_start_or_continue(:rack, {}, req.incoming_context)
19
+
20
+ unless req.correlation_data.empty?
21
+ current_span[:crid] = req.correlation_data[:id]
22
+ current_span[:crtp] = req.correlation_data[:type]
58
23
  end
59
24
 
60
- kvs = collect_kvs(env)
61
-
62
- ::Instana.tracer.log_start_or_continue(:rack, {}, incoming_context)
63
-
64
25
  status, headers, response = @app.call(env)
65
26
 
66
27
  if ::Instana.tracer.tracing?
@@ -1,11 +1,11 @@
1
- if defined?(::Redis) && ::Instana.config[:redis][:enabled]
2
- ::Redis::Client.class_eval do
3
- def call_with_instana(*args, &block)
1
+ module Instana
2
+ module RedisInstrumentation
3
+ def call(*args, &block)
4
4
  kv_payload = { redis: {} }
5
5
  dnt_spans = [:redis, :'resque-client', :'sidekiq-client']
6
6
 
7
- if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name)
8
- return call_without_instana(*args, &block)
7
+ if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name) || !Instana.config[:redis][:enabled]
8
+ return super(*args, &block)
9
9
  end
10
10
 
11
11
  begin
@@ -19,7 +19,7 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
19
19
  nil
20
20
  end
21
21
 
22
- call_without_instana(*args, &block)
22
+ super(*args, &block)
23
23
  rescue => e
24
24
  ::Instana.tracer.log_info({ redis: {error: true} })
25
25
  ::Instana.tracer.log_error(e)
@@ -29,17 +29,12 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
29
29
  end
30
30
  end
31
31
 
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)
32
+ def call_pipeline(*args, &block)
38
33
  kv_payload = { redis: {} }
39
34
  dnt_spans = [:redis, :'resque-client', :'sidekiq-client']
40
35
 
41
- if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name)
42
- return call_pipeline_without_instana(*args, &block)
36
+ if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name) || !Instana.config[:redis][:enabled]
37
+ return super(*args, &block)
43
38
  end
44
39
 
45
40
  begin
@@ -54,7 +49,7 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
54
49
  nil
55
50
  end
56
51
 
57
- call_pipeline_without_instana(*args, &block)
52
+ super(*args, &block)
58
53
  rescue => e
59
54
  ::Instana.tracer.log_info({ redis: {error: true} })
60
55
  ::Instana.tracer.log_error(e)
@@ -63,8 +58,5 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
63
58
  ::Instana.tracer.log_exit(:redis, kv_payload)
64
59
  end
65
60
  end
66
-
67
- alias call_pipeline_without_instana call_pipeline
68
- alias call_pipeline call_pipeline_with_instana
69
61
  end
70
62
  end
@@ -3,11 +3,8 @@ require 'socket'
3
3
  module Instana
4
4
  module Instrumentation
5
5
  module ResqueClient
6
- def self.included(klass)
6
+ def self.prepended(klass)
7
7
  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
8
  end
12
9
 
13
10
  def collect_kvs(op, klass, args)
@@ -23,50 +20,46 @@ module Instana
23
20
  { :'resque-client' => kvs }
24
21
  end
25
22
 
26
- def enqueue_with_instana(klass, *args)
23
+ def enqueue(klass, *args)
27
24
  if Instana.tracer.tracing?
28
25
  kvs = collect_kvs(:enqueue, klass, args)
29
26
 
30
27
  Instana.tracer.trace(:'resque-client', kvs) do
31
- enqueue_without_instana(klass, *args)
28
+ super(klass, *args)
32
29
  end
33
30
  else
34
- enqueue_without_instana(klass, *args)
31
+ super(klass, *args)
35
32
  end
36
33
  end
37
34
 
38
- def enqueue_to_with_instana(queue, klass, *args)
35
+ def enqueue_to(queue, klass, *args)
39
36
  if Instana.tracer.tracing? && !Instana.tracer.tracing_span?(:'resque-client')
40
37
  kvs = collect_kvs(:enqueue_to, klass, args)
41
38
  kvs[:Queue] = queue.to_s if queue
42
39
 
43
40
  Instana.tracer.trace(:'resque-client', kvs) do
44
- enqueue_to_without_instana(queue, klass, *args)
41
+ super(queue, klass, *args)
45
42
  end
46
43
  else
47
- enqueue_to_without_instana(queue, klass, *args)
44
+ super(queue, klass, *args)
48
45
  end
49
46
  end
50
47
 
51
- def dequeue_with_instana(klass, *args)
48
+ def dequeue(klass, *args)
52
49
  if Instana.tracer.tracing?
53
50
  kvs = collect_kvs(:dequeue, klass, args)
54
51
 
55
52
  Instana.tracer.trace(:'resque-client', kvs) do
56
- dequeue_without_instana(klass, *args)
53
+ super(klass, *args)
57
54
  end
58
55
  else
59
- dequeue_without_instana(klass, *args)
56
+ super(klass, *args)
60
57
  end
61
58
  end
62
59
  end
63
60
 
64
61
  module ResqueWorker
65
- def self.included(klass)
66
- ::Instana::Util.method_alias(klass, :perform)
67
- end
68
-
69
- def perform_with_instana(job)
62
+ def perform(job)
70
63
  kvs = {}
71
64
  kvs[:'resque-worker'] = {}
72
65
 
@@ -81,17 +74,13 @@ module Instana
81
74
  end
82
75
 
83
76
  Instana.tracer.start_or_continue_trace(:'resque-worker', kvs) do
84
- perform_without_instana(job)
77
+ super(job)
85
78
  end
86
79
  end
87
80
  end
88
81
 
89
82
  module ResqueJob
90
- def self.included(klass)
91
- ::Instana::Util.method_alias(klass, :fail)
92
- end
93
-
94
- def fail_with_instana(exception)
83
+ def fail(exception)
95
84
  if Instana.tracer.tracing?
96
85
  ::Instana.tracer.log_info(:'resque-worker' => { :error => "#{exception.class}: #{exception}"})
97
86
  ::Instana.tracer.log_error(exception)
@@ -99,33 +88,8 @@ module Instana
99
88
  rescue Exception => e
100
89
  ::Instana.logger.debug { "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" } if Instana::Config[:verbose]
101
90
  ensure
102
- fail_without_instana(exception)
91
+ super(exception)
103
92
  end
104
93
  end
105
94
  end
106
95
  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,19 @@
1
1
  module Instana
2
2
  module Instrumentation
3
3
  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
4
+ def execute(&block)
14
5
  # Since RestClient uses net/http under the covers, we just
15
6
  # provide span visibility here. HTTP related KVs are reported
16
7
  # in the Net::HTTP instrumentation
17
8
  ::Instana.tracer.log_entry(:'rest-client')
18
9
 
19
- execute_without_instana(&block)
10
+ super(&block)
20
11
  rescue => e
21
12
  ::Instana.tracer.log_error(e)
22
13
  raise
23
14
  ensure
24
15
  ::Instana.tracer.log_exit(:'rest-client')
25
16
  end
26
-
27
17
  end
28
18
  end
29
19
  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