traceview 3.8.0 → 3.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/README.md +3 -3
  4. data/lib/joboe_metal.rb +4 -4
  5. data/lib/oboe_metal.rb +3 -3
  6. data/lib/traceview/api/layerinit.rb +2 -2
  7. data/lib/traceview/api/logging.rb +12 -12
  8. data/lib/traceview/api/profiling.rb +6 -6
  9. data/lib/traceview/api/tracing.rb +1 -1
  10. data/lib/traceview/api/util.rb +1 -1
  11. data/lib/traceview/base.rb +14 -7
  12. data/lib/traceview/config.rb +8 -5
  13. data/lib/traceview/frameworks/padrino/templates.rb +4 -4
  14. data/lib/traceview/frameworks/rails.rb +2 -2
  15. data/lib/traceview/frameworks/rails/inst/action_controller.rb +6 -2
  16. data/lib/traceview/frameworks/rails/inst/action_controller2.rb +4 -2
  17. data/lib/traceview/frameworks/rails/inst/action_controller3.rb +5 -4
  18. data/lib/traceview/frameworks/rails/inst/action_controller4.rb +4 -2
  19. data/lib/traceview/frameworks/rails/inst/action_controller5.rb +22 -11
  20. data/lib/traceview/frameworks/rails/inst/action_controller5_api.rb +23 -12
  21. data/lib/traceview/frameworks/sinatra/templates.rb +4 -4
  22. data/lib/traceview/inst/bunny-client.rb +8 -8
  23. data/lib/traceview/inst/bunny-consumer.rb +1 -1
  24. data/lib/traceview/inst/curb.rb +19 -19
  25. data/lib/traceview/inst/dalli.rb +4 -4
  26. data/lib/traceview/inst/delayed_job.rb +4 -4
  27. data/lib/traceview/inst/em-http-request.rb +6 -6
  28. data/lib/traceview/inst/excon.rb +18 -18
  29. data/lib/traceview/inst/faraday.rb +13 -13
  30. data/lib/traceview/inst/http.rb +12 -12
  31. data/lib/traceview/inst/httpclient.rb +19 -19
  32. data/lib/traceview/inst/memcache.rb +5 -5
  33. data/lib/traceview/inst/memcached.rb +4 -4
  34. data/lib/traceview/inst/mongo.rb +6 -6
  35. data/lib/traceview/inst/moped.rb +28 -28
  36. data/lib/traceview/inst/rack.rb +24 -24
  37. data/lib/traceview/inst/redis.rb +6 -6
  38. data/lib/traceview/inst/resque.rb +6 -6
  39. data/lib/traceview/inst/rest-client.rb +4 -4
  40. data/lib/traceview/inst/sequel.rb +12 -12
  41. data/lib/traceview/inst/sidekiq-client.rb +3 -3
  42. data/lib/traceview/inst/sidekiq-worker.rb +3 -3
  43. data/lib/traceview/inst/twitter-cassandra.rb +17 -17
  44. data/lib/traceview/inst/typhoeus.rb +13 -13
  45. data/lib/traceview/method_profiling.rb +2 -2
  46. data/lib/traceview/ruby.rb +1 -1
  47. data/lib/traceview/util.rb +4 -4
  48. data/lib/traceview/version.rb +1 -1
  49. data/test/frameworks/rails3x_test.rb +105 -0
  50. data/test/frameworks/rails4x_test.rb +97 -0
  51. data/test/frameworks/rails5x_api_test.rb +98 -1
  52. data/test/frameworks/rails5x_test.rb +99 -2
  53. data/test/profiling/legacy_method_profiling_test.rb +1 -1
  54. data/test/support/backcompat_test.rb +2 -2
  55. data/test/support/config_test.rb +1 -1
  56. metadata +2 -2
@@ -20,12 +20,14 @@ module TraceView
20
20
  end
21
21
 
22
22
  def process_action_with_traceview(method_name, *args)
23
- report_kvs = {
23
+ kvs = {
24
24
  :Controller => self.class.name,
25
25
  :Action => self.action_name,
26
26
  }
27
+ kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:action_controller][:collect_backtraces]
28
+
29
+ TraceView::API.log_entry('rails', kvs)
27
30
 
28
- TraceView::API.log_entry('rails', report_kvs)
29
31
  process_action_without_traceview(method_name, *args)
30
32
 
31
33
  rescue Exception => e
@@ -12,21 +12,15 @@ module TraceView
12
12
  module ActionController
13
13
  include ::TraceView::Inst::RailsBase
14
14
 
15
- def self.included(base)
16
- base.class_eval do
17
- alias_method_chain :process_action, :traceview
18
- alias_method_chain :render, :traceview
19
- end
20
- end
21
-
22
- def process_action_with_traceview(method_name, *args)
23
- report_kvs = {
15
+ def process_action(method_name, *args)
16
+ kvs = {
24
17
  :Controller => self.class.name,
25
18
  :Action => self.action_name,
26
19
  }
20
+ kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:action_controller][:collect_backtraces]
27
21
 
28
- TraceView::API.log_entry('rails', report_kvs)
29
- process_action_without_traceview(method_name, *args)
22
+ TraceView::API.log_entry('rails', kvs)
23
+ super(method_name, *args)
30
24
 
31
25
  rescue Exception => e
32
26
  TraceView::API.log_exception(nil, e) if log_rails_error?(e)
@@ -34,6 +28,23 @@ module TraceView
34
28
  ensure
35
29
  TraceView::API.log_exit('rails')
36
30
  end
31
+
32
+ #
33
+ # render_with_traceview
34
+ #
35
+ # Our render wrapper that just times and conditionally
36
+ # reports raised exceptions
37
+ #
38
+ def render(*args, &blk)
39
+ TraceView::API.log_entry('actionview')
40
+ super(*args, &blk)
41
+
42
+ rescue Exception => e
43
+ TraceView::API.log_exception(nil, e) if log_rails_error?(e)
44
+ raise
45
+ ensure
46
+ TraceView::API.log_exit('actionview')
47
+ end
37
48
  end
38
49
  end
39
50
  end
@@ -7,26 +7,20 @@ module TraceView
7
7
  # ActionController
8
8
  #
9
9
  # This modules contains the instrumentation code specific
10
- # to Rails v5
10
+ # to Rails v5.
11
11
  #
12
12
  module ActionControllerAPI
13
13
  include ::TraceView::Inst::RailsBase
14
14
 
15
- def self.included(base)
16
- base.class_eval do
17
- alias_method_chain :process_action, :traceview
18
- alias_method_chain :render, :traceview
19
- end
20
- end
21
-
22
- def process_action_with_traceview(method_name, *args)
23
- report_kvs = {
15
+ def process_action(method_name, *args)
16
+ kvs = {
24
17
  :Controller => self.class.name,
25
18
  :Action => self.action_name,
26
19
  }
20
+ kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:action_controller_api][:collect_backtraces]
27
21
 
28
- TraceView::API.log_entry('rails-api', report_kvs)
29
- process_action_without_traceview(method_name, *args)
22
+ TraceView::API.log_entry('rails-api', kvs)
23
+ super(method_name, *args)
30
24
 
31
25
  rescue Exception => e
32
26
  TraceView::API.log_exception(nil, e) if log_rails_error?(e)
@@ -34,6 +28,23 @@ module TraceView
34
28
  ensure
35
29
  TraceView::API.log_exit('rails-api')
36
30
  end
31
+
32
+ #
33
+ # render
34
+ #
35
+ # Our render wrapper that just times and conditionally
36
+ # reports raised exceptions
37
+ #
38
+ def render(*args, &blk)
39
+ TraceView::API.log_entry('actionview')
40
+ super(*args, &blk)
41
+
42
+ rescue Exception => e
43
+ TraceView::API.log_exception(nil, e) if log_rails_error?(e)
44
+ raise
45
+ ensure
46
+ TraceView::API.log_exit('actionview')
47
+ end
37
48
  end
38
49
  end
39
50
  end
@@ -15,14 +15,14 @@ module TraceView
15
15
  report_kvs[:engine] = engine
16
16
  report_kvs[:template] = data
17
17
 
18
- if TraceView.tracing_layer_op?('render')
18
+ if TraceView.tracing_layer_op?(:render)
19
19
  # For recursive calls to :render (for sub-partials and layouts),
20
20
  # use method profiling.
21
21
  begin
22
22
  name = data
23
23
  report_kvs[:FunctionName] = :render
24
24
  report_kvs[:Class] = :Templates
25
- report_kvs[:Module] = 'Sinatra::Templates'
25
+ report_kvs[:Module] = :'Sinatra::Templates'
26
26
  report_kvs[:File] = __FILE__
27
27
  report_kvs[:LineNumber] = __LINE__
28
28
  rescue StandardError => e
@@ -39,12 +39,12 @@ module TraceView
39
39
  # back on exit (a limitation of the TraceView::API.trace
40
40
  # block method) This removes the need for an info
41
41
  # event to send additonal KVs
42
- ::TraceView::API.log_entry('render', {}, 'render')
42
+ ::TraceView::API.log_entry(:render, {}, :render)
43
43
 
44
44
  begin
45
45
  render_without_traceview(engine, data, options, locals, &block)
46
46
  ensure
47
- ::TraceView::API.log_exit('render', report_kvs)
47
+ ::TraceView::API.log_exit(:render, report_kvs)
48
48
  end
49
49
  end
50
50
  else
@@ -28,14 +28,14 @@ module TraceView
28
28
  kvs[:ExchangeName] = :default
29
29
  end
30
30
 
31
- TraceView::API.log_entry('rabbitmq-client')
31
+ TraceView::API.log_entry(:'rabbitmq-client')
32
32
 
33
33
  delete_without_traceview(opts)
34
34
  rescue => e
35
35
  TraceView::API.log_exception(nil, e)
36
36
  raise e
37
37
  ensure
38
- TraceView::API.log_exit('rabbitmq-client', kvs)
38
+ TraceView::API.log_exit(:'rabbitmq-client', kvs)
39
39
  end
40
40
  end
41
41
  end
@@ -83,7 +83,7 @@ module TraceView
83
83
  kvs[:RoutingKey] = routing_key if routing_key
84
84
  kvs[:Op] = :publish
85
85
 
86
- TraceView::API.log_entry('rabbitmq-client')
86
+ TraceView::API.log_entry(:'rabbitmq-client')
87
87
 
88
88
  # Pass the tracing context as a header
89
89
  opts[:headers] ||= {}
@@ -94,7 +94,7 @@ module TraceView
94
94
  TraceView::API.log_exception(nil, e)
95
95
  raise e
96
96
  ensure
97
- TraceView::API.log_exit('rabbitmq-client', kvs)
97
+ TraceView::API.log_exit(:'rabbitmq-client', kvs)
98
98
  end
99
99
  end
100
100
 
@@ -106,7 +106,7 @@ module TraceView
106
106
  kvs = collect_channel_kvs
107
107
  kvs[:Op] = :queue
108
108
 
109
- TraceView::API.log_entry('rabbitmq-client')
109
+ TraceView::API.log_entry(:'rabbitmq-client')
110
110
 
111
111
  result = queue_without_traceview(name, opts)
112
112
  kvs[:Queue] = result.name
@@ -115,7 +115,7 @@ module TraceView
115
115
  TraceView::API.log_exception(nil, e)
116
116
  raise e
117
117
  ensure
118
- TraceView::API.log_exit('rabbitmq-client', kvs)
118
+ TraceView::API.log_exit(:'rabbitmq-client', kvs)
119
119
  end
120
120
  end
121
121
 
@@ -127,14 +127,14 @@ module TraceView
127
127
  kvs = collect_channel_kvs
128
128
  kvs[:Op] = :wait_for_confirms
129
129
 
130
- TraceView::API.log_entry('rabbitmq-client')
130
+ TraceView::API.log_entry(:'rabbitmq-client')
131
131
 
132
132
  wait_for_confirms_without_traceview
133
133
  rescue => e
134
134
  TraceView::API.log_exception(nil, e)
135
135
  raise e
136
136
  ensure
137
- TraceView::API.log_exit('rabbitmq-client', kvs)
137
+ TraceView::API.log_exit(:'rabbitmq-client', kvs)
138
138
  end
139
139
  end
140
140
  end
@@ -77,7 +77,7 @@ module TraceView
77
77
  headers.delete('SourceTrace')
78
78
  end
79
79
 
80
- result = TraceView::API.start_trace('rabbitmq-consumer', nil, report_kvs) do
80
+ result = TraceView::API.start_trace(:'rabbitmq-consumer', nil, report_kvs) do
81
81
  call_without_traceview(*args)
82
82
  end
83
83
  result[0]
@@ -19,7 +19,7 @@ module TraceView
19
19
  kvs = {}
20
20
 
21
21
  if TraceView::Config[:curb][:cross_host]
22
- kvs['IsService'] = 1
22
+ kvs[:IsService] = 1
23
23
 
24
24
  # Conditionally log query args
25
25
  if TraceView::Config[:curb][:log_args]
@@ -33,7 +33,7 @@ module TraceView
33
33
 
34
34
  # Avoid cross host tracing for blacklisted domains
35
35
  kvs[:blacklisted] = TraceView::API.blacklisted?(URI(url).hostname)
36
- kvs['Backtrace'] = TraceView::API.backtrace if TraceView::Config[:curb][:collect_backtraces]
36
+ kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:curb][:collect_backtraces]
37
37
 
38
38
  kvs
39
39
  rescue => e
@@ -59,7 +59,7 @@ module TraceView
59
59
  handle_cross_host = TraceView::Config[:curb][:cross_host]
60
60
  kvs.merge! traceview_collect
61
61
 
62
- TraceView::API.log_entry('curb', kvs)
62
+ TraceView::API.log_entry(:curb, kvs)
63
63
  kvs.clear
64
64
 
65
65
  if handle_cross_host && !kvs[:blacklisted]
@@ -71,11 +71,11 @@ module TraceView
71
71
  response = self.send(method, *args, &block)
72
72
 
73
73
  if handle_cross_host
74
- kvs['HTTPStatus'] = response_code
74
+ kvs[:HTTPStatus] = response_code
75
75
 
76
76
  # If we get a redirect, report the location header
77
77
  if ((300..308).to_a.include? response_code) && headers.key?("Location")
78
- kvs["Location"] = headers["Location"]
78
+ kvs[:Location] = headers["Location"]
79
79
  end
80
80
 
81
81
  # Curb only provides a single long string of all response headers (yuck!). So we are forced
@@ -92,10 +92,10 @@ module TraceView
92
92
 
93
93
  response
94
94
  rescue => e
95
- TraceView::API.log_exception('curb', e)
95
+ TraceView::API.log_exception(:curb, e)
96
96
  raise e
97
97
  ensure
98
- TraceView::API.log_exit('curb', kvs)
98
+ TraceView::API.log_exit(:curb, kvs)
99
99
  end
100
100
 
101
101
  end
@@ -120,7 +120,7 @@ module TraceView
120
120
  #
121
121
  def http_post_with_traceview(*args, &block)
122
122
  # If we're not tracing, just do a fast return.
123
- if !TraceView.tracing? || TraceView.tracing_layer?('curb')
123
+ if !TraceView.tracing? || TraceView.tracing_layer?(:curb)
124
124
  return http_post_without_traceview(*args)
125
125
  end
126
126
 
@@ -139,7 +139,7 @@ module TraceView
139
139
  #
140
140
  def http_put_with_traceview(*args, &block)
141
141
  # If we're not tracing, just do a fast return.
142
- if !TraceView.tracing? || TraceView.tracing_layer?('curb')
142
+ if !TraceView.tracing? || TraceView.tracing_layer?(:curb)
143
143
  return http_put_without_traceview(data)
144
144
  end
145
145
 
@@ -158,7 +158,7 @@ module TraceView
158
158
  #
159
159
  def perform_with_traceview(&block)
160
160
  # If we're not tracing, just do a fast return.
161
- if !TraceView.tracing? || TraceView.tracing_layer?('curb')
161
+ if !TraceView.tracing? || TraceView.tracing_layer?(:curb)
162
162
  return perform_without_traceview(&block)
163
163
  end
164
164
 
@@ -219,17 +219,17 @@ module TraceView
219
219
 
220
220
  begin
221
221
  kvs = {}
222
- kvs['Backtrace'] = TraceView::API.backtrace if TraceView::Config[:curb][:collect_backtraces]
222
+ kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:curb][:collect_backtraces]
223
223
 
224
- TraceView::API.log_entry('curb_multi', kvs)
224
+ TraceView::API.log_entry(:curb_multi, kvs)
225
225
 
226
226
  # The core curb call
227
227
  http_without_traceview(urls_with_config, multi_options, &block)
228
228
  rescue => e
229
- TraceView::API.log_exception('curb_multi', e)
229
+ TraceView::API.log_exception(:curb_multi, e)
230
230
  raise e
231
231
  ensure
232
- TraceView::API.log_exit('curb_multi')
232
+ TraceView::API.log_exit(:curb_multi)
233
233
  end
234
234
  end
235
235
  end
@@ -252,23 +252,23 @@ module TraceView
252
252
  #
253
253
  def perform_with_traceview(&block)
254
254
  # If we're not tracing or we're not already tracing curb, just do a fast return.
255
- if !TraceView.tracing? || ['curb', 'curb_multi'].include?(TraceView.layer)
255
+ if !TraceView.tracing? || [:curb, :curb_multi].include?(TraceView.layer)
256
256
  return perform_without_traceview(&block)
257
257
  end
258
258
 
259
259
  begin
260
260
  kvs = {}
261
- kvs['Backtrace'] = TraceView::API.backtrace if TraceView::Config[:curb][:collect_backtraces]
261
+ kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:curb][:collect_backtraces]
262
262
 
263
- TraceView::API.log_entry('curb_multi', kvs)
263
+ TraceView::API.log_entry(:curb_multi, kvs)
264
264
 
265
265
  # The core curb call
266
266
  perform_without_traceview(&block)
267
267
  rescue => e
268
- TraceView::API.log_exception('curb_multi', e)
268
+ TraceView::API.log_exception(:curb_multi, e)
269
269
  raise e
270
270
  ensure
271
- TraceView::API.log_exit('curb_multi')
271
+ TraceView::API.log_exit(:curb_multi)
272
272
  end
273
273
  end
274
274
  end
@@ -33,7 +33,7 @@ module TraceView
33
33
  end
34
34
 
35
35
  if TraceView.tracing? && !TraceView.tracing_layer_op?(:get_multi)
36
- TraceView::API.trace('memcache', report_kvs) do
36
+ TraceView::API.trace(:memcache, report_kvs) do
37
37
  result = perform_without_traceview(*all_args, &blk)
38
38
 
39
39
  # Clear the hash for a potential info event
@@ -41,7 +41,7 @@ module TraceView
41
41
  report_kvs[:KVHit] = memcache_hit?(result) if op == :get && key.class == String
42
42
  report_kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:dalli][:collect_backtraces]
43
43
 
44
- TraceView::API.log('memcache', 'info', report_kvs) unless report_kvs.empty?
44
+ TraceView::API.log(:memcache, :info, report_kvs) unless report_kvs.empty?
45
45
  result
46
46
  end
47
47
  else
@@ -64,12 +64,12 @@ module TraceView
64
64
  TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" if TraceView::Config[:verbose]
65
65
  end
66
66
 
67
- TraceView::API.trace('memcache', { :KVOp => :get_multi }, :get_multi) do
67
+ TraceView::API.trace(:memcache, { :KVOp => :get_multi }, :get_multi) do
68
68
  values = get_multi_without_traceview(*keys)
69
69
 
70
70
  info_kvs[:KVHitCount] = values.length
71
71
  info_kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:dalli][:collect_backtraces]
72
- TraceView::API.log('memcache', 'info', info_kvs)
72
+ TraceView::API.log(:memcache, :info, info_kvs)
73
73
 
74
74
  values
75
75
  end
@@ -44,9 +44,9 @@ if defined?(::Delayed)
44
44
  report_kvs[:JobName] = job.name
45
45
  report_kvs[:MsgID] = job.id
46
46
  report_kvs[:Queue] = job.queue if job.queue
47
- report_kvs['Backtrace'] = TV::API.backtrace if TV::Config[:delayed_jobclient][:collect_backtraces]
47
+ report_kvs[:Backtrace] = TV::API.backtrace if TV::Config[:delayed_jobclient][:collect_backtraces]
48
48
 
49
- TraceView::API.trace('delayed_job-client', report_kvs) do
49
+ TraceView::API.trace(:'delayed_job-client', report_kvs) do
50
50
  block.call(job)
51
51
  end
52
52
  end
@@ -63,7 +63,7 @@ if defined?(::Delayed)
63
63
  report_kvs[:JobName] = job.name
64
64
  report_kvs[:MsgID] = job.id
65
65
  report_kvs[:Queue] = job.queue if job.queue
66
- report_kvs['Backtrace'] = TV::API.backtrace if TV::Config[:delayed_jobworker][:collect_backtraces]
66
+ report_kvs[:Backtrace] = TV::API.backtrace if TV::Config[:delayed_jobworker][:collect_backtraces]
67
67
 
68
68
  # DelayedJob Specific KVs
69
69
  report_kvs[:priority] = job.priority
@@ -73,7 +73,7 @@ if defined?(::Delayed)
73
73
  TV.logger.warn "[traceview/warning] inst/delayed_job.rb: #{e.message}"
74
74
  end
75
75
 
76
- result = TraceView::API.start_trace('delayed_job-worker', nil, report_kvs) do
76
+ result = TraceView::API.start_trace(:'delayed_job-worker', nil, report_kvs) do
77
77
  block.call(worker, job)
78
78
  TV::API.log_exception(nil, job.error) if job.error
79
79
  end
@@ -11,10 +11,10 @@ module TraceView
11
11
  blacklisted = TraceView::API.blacklisted?(@uri)
12
12
 
13
13
  begin
14
- report_kvs['IsService'] = 1
15
- report_kvs['RemoteURL'] = @uri
16
- report_kvs['HTTPMethod'] = args[0]
17
- report_kvs['Blacklisted'] = true if blacklisted
14
+ report_kvs[:IsService] = 1
15
+ report_kvs[:RemoteURL] = @uri
16
+ report_kvs[:HTTPMethod] = args[0]
17
+ report_kvs[:Blacklisted] = true if blacklisted
18
18
 
19
19
  if TraceView::Config[:em_http_request][:collect_backtraces]
20
20
  report_kvs[:Backtrace] = TraceView::API.backtrace
@@ -23,7 +23,7 @@ module TraceView
23
23
  TraceView.logger.debug "[traceview/debug] em-http-request KV error: #{e.inspect}"
24
24
  end
25
25
 
26
- ::TraceView::API.log_entry('em-http-request', report_kvs)
26
+ ::TraceView::API.log_entry(:'em-http-request', report_kvs)
27
27
  client = setup_request_without_traceview(*args, &block)
28
28
  client.req.headers['X-Trace'] = context unless blacklisted
29
29
  client
@@ -66,7 +66,7 @@ module TraceView
66
66
 
67
67
  end
68
68
 
69
- ::TraceView::API.log_exit('em-http-request', report_kvs)
69
+ ::TraceView::API.log_exit(:'em-http-request', report_kvs)
70
70
  end
71
71
  end
72
72
  end