traceview 3.3.1-java → 3.3.3-java

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
  SHA1:
3
- metadata.gz: 4b9ad084f3593aa0b7691b9a9da5c9bee8d5d21d
4
- data.tar.gz: b14cde0f95322411bdc31dc0a5559624a30a6e69
3
+ metadata.gz: ba9ede32f6b82764e4c1f79575f13195e60365cc
4
+ data.tar.gz: 7c4fd3b02180e75ff31c4e0ffb0244377bf680a4
5
5
  SHA512:
6
- metadata.gz: ca2e2c2b315a198b69b6f93e409e6deeb80b6ae142ecb94a124255b2d361781774f62e4e3c6fe9129a6e63b200d30c788b9757adbe92e26f0f8d269426675b0b
7
- data.tar.gz: a1d5cada103fd3e15123833c7afb551ddf479875aa1e1a8a6c15c55c3a51edbbdea47318c8779fb71efddaca5c8ef60745c9e0fc405c7b5a54ccc3a02fbe5299
6
+ metadata.gz: af167e8b74c3d2ca7186d6c6112ec965f6aab6cff43ee9f2bbc42a0fc94081904909047babac08f7149cdc89958f1d3ed4f59822d36b09fea62ce14f42600a7e
7
+ data.tar.gz: 4374aa1626b0d93804e27b3f6d92b1eee7491fa4c7455ad5cedd19aefd668ee5c94b404ffec22a7f8d4f1b47764c635ba9ab7842e976f1a3adc5e0be28f650e8
data/.travis.yml CHANGED
@@ -7,12 +7,9 @@ cache:
7
7
 
8
8
  rvm:
9
9
  - 2.2.3
10
- - 2.1.7
11
- - 2.0.0
12
10
  - 1.9.3
13
11
  - 1.8.7
14
- - ree
15
- - jruby-19mode
12
+ - jruby-9.0.0.0
16
13
 
17
14
  gemfile:
18
15
  - gemfiles/libraries.gemfile
data/CHANGELOG.md CHANGED
@@ -4,6 +4,21 @@ https://github.com/appneta/oboe-ruby/releases
4
4
 
5
5
  Dates in this file are in the format MM/DD/YYYY.
6
6
 
7
+ # traceview 3.3.3
8
+
9
+ This patch release includes the following fixes:
10
+
11
+ * Sidekiq instrumentation: don't carry context between enqueue and job run: #150
12
+ * Sidekiq instrumentation: Update KV reporting to follow TV specs: #150
13
+ * Resque instrumentation: Update instrumentation to follow TV specs: #146
14
+ * Resque instrumentation: `:link_workers` option deprecated: #146
15
+ * [JRuby 9000](http://jruby.org/) validated: Add JRuby 9000 to test suite: #149
16
+
17
+ Pushed to Rubygems:
18
+
19
+ https://rubygems.org/gems/traceview/versions/3.3.2
20
+ https://rubygems.org/gems/traceview/versions/3.3.2-java
21
+
7
22
  # traceview 3.3.1
8
23
 
9
24
  This patch release includes the following fixes:
data/Rakefile CHANGED
@@ -124,4 +124,12 @@ task :console do
124
124
  Pry.start
125
125
  end
126
126
 
127
-
127
+ # Used when testing Resque locally
128
+ task "resque:setup" do
129
+ require 'resque/tasks'
130
+ require 'traceview/test'
131
+ ENV['TRACEVIEW_GEM_VERBOSE'] = 'true'
132
+ Bundler.require(:default, :development)
133
+ TraceView::Config[:tracing_mode] = :always
134
+ TV::Test.load_extras
135
+ end
@@ -52,11 +52,12 @@ gem 'httpclient'
52
52
  gem 'memcache-client'
53
53
  gem 'mongo'
54
54
  gem 'redis'
55
- gem 'resque'
55
+ gem 'resque' unless defined?(JRUBY_VERSION) && RUBY_VERSION > '1.9.3'
56
56
  gem 'sequel'
57
57
  gem "sidekiq" if RUBY_VERSION >= '2.0'
58
58
  gem 'typhoeus'
59
59
 
60
+
60
61
  # Database adapter gems needed by sequel
61
62
  if defined?(JRUBY_VERSION)
62
63
  gem 'jdbc-postgresql'
@@ -14,8 +14,8 @@ module TraceView
14
14
  @@instrumentation = [:action_controller, :action_view, :active_record,
15
15
  :cassandra, :curb, :dalli, :em_http_request, :excon, :faraday,
16
16
  :grape, :httpclient, :nethttp, :memcached, :memcache, :mongo,
17
- :moped, :rack, :redis, :resque, :rest_client, :sequel, :sidekiqclient,
18
- :sidekiqworker, :typhoeus]
17
+ :moped, :rack, :redis, :resqueclient, :resqueworker,
18
+ :rest_client, :sequel, :sidekiqclient, :sidekiqworker, :typhoeus]
19
19
 
20
20
  # Subgrouping of instrumentation
21
21
  @@http_clients = [:curb, :excon, :em_http_request, :faraday, :httpclient, :nethttp, :rest_client, :typhoeus]
@@ -57,21 +57,16 @@ module TraceView
57
57
  TraceView::Config[:moped][:collect_backtraces] = true
58
58
  TraceView::Config[:nethttp][:collect_backtraces] = true
59
59
  TraceView::Config[:redis][:collect_backtraces] = false
60
- TraceView::Config[:resque][:collect_backtraces] = true
60
+ TraceView::Config[:resqueclient][:collect_backtraces] = true
61
+ TraceView::Config[:resqueworker][:collect_backtraces] = false
61
62
  TraceView::Config[:rest_client][:collect_backtraces] = false
62
63
  TraceView::Config[:sequel][:collect_backtraces] = true
63
64
  TraceView::Config[:sidekiqclient][:collect_backtraces] = false
64
65
  TraceView::Config[:sidekiqworker][:collect_backtraces] = false
65
66
  TraceView::Config[:typhoeus][:collect_backtraces] = false
66
67
 
67
- # Special instrument specific flags
68
- #
69
- # :link_workers - associates enqueue operations with the jobs they queue by piggybacking
70
- # an additional argument that is stripped prior to job proecessing
71
- # !!Note: Make sure both the queue side and the Resque workers are instrumented
72
- # or jobs will fail
73
- # (Default: false)
74
- @@config[:resque][:link_workers] = false
68
+ # Legacy Resque config support. To be removed in a future version
69
+ @@config[:resque] = {}
75
70
 
76
71
  # Setup an empty host blacklist (see: TraceView::API::Util.blacklisted?)
77
72
  @@config[:blacklist] = []
@@ -192,6 +187,11 @@ module TraceView
192
187
  end
193
188
 
194
189
  def self.[](key)
190
+ if key == :resque
191
+ TraceView.logger.warn "[traceview/warn] :resque config is deprecated. It is now split into :resqueclient and :resqueworker."
192
+ TraceView.logger.warn "[traceview/warn] Called from #{Kernel.caller[0]}"
193
+ end
194
+
195
195
  @@config[key.to_sym]
196
196
  end
197
197
 
@@ -219,6 +219,10 @@ module TraceView
219
219
  elsif key == :action_blacklist
220
220
  TraceView.logger.warn "[traceview/unsupported] :action_blacklist has been deprecated and no longer functions."
221
221
 
222
+ elsif key == :resque
223
+ TraceView.logger.warn "[traceview/warn] :resque config is deprecated. It is now split into :resqueclient and :resqueworker."
224
+ TraceView.logger.warn "[traceview/warn] Called from #{Kernel.caller[0]}"
225
+
222
226
  elsif key == :include_url_query_params
223
227
  # Obey the global flag and update all of the per instrumentation
224
228
  # <tt>:log_args</tt> values.
@@ -6,19 +6,23 @@ require 'json'
6
6
 
7
7
  module TraceView
8
8
  module Inst
9
- module Resque
10
- def self.included(base)
11
- base.send :extend, ::Resque
9
+ module ResqueClient
10
+ def self.included(klass)
11
+ klass.send :extend, ::Resque
12
+ ::TraceView::Util.method_alias(klass, :enqueue, ::Resque)
13
+ ::TraceView::Util.method_alias(klass, :enqueue_to, ::Resque)
14
+ ::TraceView::Util.method_alias(klass, :dequeue, ::Resque)
12
15
  end
13
16
 
14
17
  def extract_trace_details(op, klass, args)
15
18
  report_kvs = {}
16
19
 
17
20
  begin
18
- report_kvs[:Op] = op.to_s
19
- report_kvs[:Class] = klass.to_s if klass
21
+ report_kvs[:Spec] = :pushq
22
+ report_kvs[:Flavor] = :resque
23
+ report_kvs[:JobName] = klass.to_s
20
24
 
21
- if TraceView::Config[:resque][:log_args]
25
+ if TraceView::Config[:resqueclient][:log_args]
22
26
  kv_args = args.to_json
23
27
 
24
28
  # Limit the argument json string to 1024 bytes
@@ -29,8 +33,10 @@ module TraceView
29
33
  end
30
34
  end
31
35
 
32
- report_kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:resque][:collect_backtraces]
33
- rescue
36
+ report_kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:resqueclient][:collect_backtraces]
37
+ report_kvs[:Queue] = klass.instance_variable_get(:@queue)
38
+ rescue => e
39
+ TraceView.logger.debug "[traceview/resque] Error collecting resqueclient KVs: #{e.message}"
34
40
  end
35
41
 
36
42
  report_kvs
@@ -41,7 +47,6 @@ module TraceView
41
47
  report_kvs = extract_trace_details(:enqueue, klass, args)
42
48
 
43
49
  TraceView::API.trace('resque-client', report_kvs, :enqueue) do
44
- args.push(:parent_trace_id => TraceView::Context.toString) if TraceView::Config[:resque][:link_workers]
45
50
  enqueue_without_traceview(klass, *args)
46
51
  end
47
52
  else
@@ -55,7 +60,6 @@ module TraceView
55
60
  report_kvs[:Queue] = queue.to_s if queue
56
61
 
57
62
  TraceView::API.trace('resque-client', report_kvs) do
58
- args.push(:parent_trace_id => TraceView::Context.toString) if TraceView::Config[:resque][:link_workers]
59
63
  enqueue_to_without_traceview(queue, klass, *args)
60
64
  end
61
65
  else
@@ -77,26 +81,28 @@ module TraceView
77
81
  end
78
82
 
79
83
  module ResqueWorker
84
+ def self.included(klass)
85
+ ::TraceView::Util.method_alias(klass, :perform, ::Resque::Worker)
86
+ end
87
+
80
88
  def perform_with_traceview(job)
81
89
  report_kvs = {}
82
- last_arg = nil
83
90
 
84
91
  begin
85
- report_kvs[:Op] = :perform
92
+ report_kvs[:Spec] = :job
93
+ report_kvs[:Flavor] = :resque
94
+ report_kvs[:JobName] = job.payload['class'].to_s
95
+ report_kvs[:Queue] = job.queue
86
96
 
87
97
  # Set these keys for the ability to separate out
88
98
  # background tasks into a separate app on the server-side UI
89
- report_kvs[:Controller] = :Resque
90
- report_kvs[:Action] = :perform
91
99
 
92
100
  report_kvs['HTTP-Host'] = Socket.gethostname
93
- report_kvs[:URL] = '/resque/' + job.queue
94
- report_kvs[:Method] = 'NONE'
95
- report_kvs[:Queue] = job.queue
96
-
97
- report_kvs[:Class] = job.payload['class']
101
+ report_kvs[:Controller] = "Resque_#{job.queue}"
102
+ report_kvs[:Action] = job.payload['class'].to_s
103
+ report_kvs[:URL] = "/resque/#{job.queue}/#{job.payload['class']}"
98
104
 
99
- if TraceView::Config[:resque][:log_args]
105
+ if TraceView::Config[:resqueworker][:log_args]
100
106
  kv_args = job.payload['args'].to_json
101
107
 
102
108
  # Limit the argument json string to 1024 bytes
@@ -107,35 +113,21 @@ module TraceView
107
113
  end
108
114
  end
109
115
 
110
- last_arg = job.payload['args'].last
116
+ report_kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:resqueworker][:collect_backtraces]
111
117
  rescue
112
118
  end
113
119
 
114
- if last_arg.is_a?(Hash) && last_arg.key?('parent_trace_id')
115
- begin
116
- # Since the enqueue was traced, we force trace the actual job execution and reference
117
- # the enqueue trace with ParentTraceID
118
- report_kvs[:ParentTraceID] = last_arg['parent_trace_id']
119
- job.payload['args'].pop
120
-
121
- rescue
122
- end
123
-
124
- # Force this trace regardless of sampling rate so that child trace can be
125
- # link to parent trace.
126
- TraceView::API.start_trace('resque-worker', nil, report_kvs.merge('Force' => true)) do
127
- perform_without_traceview(job)
128
- end
129
-
130
- else
131
- TraceView::API.start_trace('resque-worker', nil, report_kvs) do
132
- perform_without_traceview(job)
133
- end
120
+ TraceView::API.start_trace('resque-worker', nil, report_kvs) do
121
+ perform_without_traceview(job)
134
122
  end
135
123
  end
136
124
  end
137
125
 
138
126
  module ResqueJob
127
+ def self.included(klass)
128
+ ::TraceView::Util.method_alias(klass, :fail, ::Resque::Job)
129
+ end
130
+
139
131
  def fail_with_traceview(exception)
140
132
  if TraceView.tracing?
141
133
  TraceView::API.log_exception('resque', exception)
@@ -146,47 +138,12 @@ module TraceView
146
138
  end
147
139
  end
148
140
 
149
- if defined?(::Resque)
141
+ if defined?(::Resque) && RUBY_VERSION >= '1.9.3'
150
142
  TraceView.logger.info '[traceview/loading] Instrumenting resque' if TraceView::Config[:verbose]
151
143
 
152
- ::Resque.module_eval do
153
- include TraceView::Inst::Resque
154
-
155
- [:enqueue, :enqueue_to, :dequeue].each do |m|
156
- if method_defined?(m)
157
- module_eval "alias #{m}_without_traceview #{m}"
158
- module_eval "alias #{m} #{m}_with_traceview"
159
- elsif TraceView::Config[:verbose]
160
- TraceView.logger.warn "[traceview/loading] Couldn't properly instrument Resque (#{m}). Partial traces may occur."
161
- end
162
- end
163
- end
164
-
165
- if defined?(::Resque::Worker)
166
- ::Resque::Worker.class_eval do
167
- include TraceView::Inst::ResqueWorker
168
-
169
- if method_defined?(:perform)
170
- alias perform_without_traceview perform
171
- alias perform perform_with_traceview
172
- elsif TraceView::Config[:verbose]
173
- TraceView.logger.warn '[traceview/loading] Couldn\'t properly instrument ResqueWorker (perform). Partial traces may occur.'
174
- end
175
- end
176
- end
177
-
178
- if defined?(::Resque::Job)
179
- ::Resque::Job.class_eval do
180
- include TraceView::Inst::ResqueJob
181
-
182
- if method_defined?(:fail)
183
- alias fail_without_traceview fail
184
- alias fail fail_with_traceview
185
- elsif TraceView::Config[:verbose]
186
- TraceView.logger.warn '[traceview/loading] Couldn\'t properly instrument ResqueWorker (fail). Partial traces may occur.'
187
- end
188
- end
189
- end
144
+ ::TraceView::Util.send_include(::Resque, ::TraceView::Inst::ResqueClient)
145
+ ::TraceView::Util.send_include(::Resque::Worker, ::TraceView::Inst::ResqueWorker)
146
+ ::TraceView::Util.send_include(::Resque::Job, ::TraceView::Inst::ResqueJob)
190
147
  end
191
148
 
192
149
 
@@ -24,16 +24,14 @@ module TraceView
24
24
 
25
25
  def call(*args)
26
26
  # args: 0: worker_class, 1: msg, 2: queue, 3: redis_pool
27
-
28
- result = nil
29
27
  report_kvs = collect_kvs(args)
30
28
 
31
29
  TraceView::API.log_entry('sidekiq-client', report_kvs)
32
- args[1]['X-Trace'] = TraceView::Context.toString if TraceView.tracing?
30
+ args[1]['SourceTrace'] = TraceView::Context.toString if TraceView.tracing?
33
31
 
34
32
  result = yield
35
33
 
36
- report_kvs = { :JobID => result["jid"] }
34
+ report_kvs = { :JobID => result['jid'] }
37
35
  result
38
36
  rescue => e
39
37
  TraceView::API.log_exception('sidekiq-client', e, report_kvs)
@@ -8,20 +8,20 @@ module TraceView
8
8
  worker, msg, queue = args
9
9
 
10
10
  # Background Job Spec KVs
11
- report_kvs[:Spec] = :job
12
- report_kvs[:Flavor] = :sidekiq
13
- report_kvs[:Queue] = queue
14
- report_kvs[:Retry] = msg['retry']
15
- report_kvs[:JobName] = worker.class.to_s
16
- report_kvs[:MsgID] = msg['jid']
17
- report_kvs[:Args] = msg['args'].to_s[0..1024] if TV::Config[:sidekiqworker][:log_args]
18
- report_kvs['Backtrace'] = TV::API.backtrace if TV::Config[:sidekiqworker][:collect_backtraces]
11
+ report_kvs[:Spec] = :job
12
+ report_kvs[:Flavor] = :sidekiq
13
+ report_kvs[:Queue] = queue
14
+ report_kvs[:Retry] = msg['retry']
15
+ report_kvs[:JobName] = worker.class.to_s
16
+ report_kvs[:MsgID] = msg['jid']
17
+ report_kvs[:Args] = msg['args'].to_s[0..1024] if TV::Config[:sidekiqworker][:log_args]
18
+ report_kvs['Backtrace'] = TV::API.backtrace if TV::Config[:sidekiqworker][:collect_backtraces]
19
19
 
20
20
  # Webserver Spec KVs
21
21
  report_kvs['HTTP-Host'] = Socket.gethostname
22
22
  report_kvs[:Controller] = "Sidekiq_#{queue}"
23
23
  report_kvs[:Action] = msg['class']
24
- report_kvs[:URL] = "/sidekiq/#{queue}/#{msg['class'].to_s}"
24
+ report_kvs[:URL] = "/sidekiq/#{queue}/#{msg['class']}"
25
25
  rescue => e
26
26
  TraceView.logger.warn "[traceview/sidekiq] Non-fatal error capturing KVs: #{e.message}"
27
27
  end
@@ -30,17 +30,23 @@ module TraceView
30
30
 
31
31
  def call(*args)
32
32
  # args: 0: worker, 1: msg, 2: queue
33
- result = nil
34
33
  report_kvs = collect_kvs(args)
35
34
 
35
+ # Something is happening across Celluloid threads where liboboe settings
36
+ # are being lost. So we re-set the tracing mode to assure
37
+ # we sample as desired. Setting the tracing mode will re-update
38
+ # the liboboe settings.
39
+ TraceView::Config[:tracing_mode] = TraceView::Config[:tracing_mode]
40
+
36
41
  # Continue the trace from the enqueue side?
37
- incoming_context = nil
38
- if args[1].is_a?(Hash) && TraceView::XTrace.valid?(args[1]['X-Trace'])
39
- incoming_context = args[1]['X-Trace']
40
- report_kvs[:Async] = true
42
+ if args[1].is_a?(Hash) && TraceView::XTrace.valid?(args[1]['SourceTrace'])
43
+ report_kvs[:SourceTrace] = args[1]['SourceTrace']
44
+
45
+ # Pass the source trace in the TV-Meta flag field to indicate tracing
46
+ report_kvs['X-TV-Meta'] = args[1]['SourceTrace']
41
47
  end
42
48
 
43
- result = TraceView::API.start_trace('sidekiq-worker', incoming_context, report_kvs) do
49
+ result = TraceView::API.start_trace('sidekiq-worker', nil, report_kvs) do
44
50
  yield
45
51
  end
46
52
 
@@ -8,9 +8,9 @@ module TraceView
8
8
  # If we're using the libraries gemfile (with sidekiq and resque)
9
9
  if File.basename(ENV['BUNDLE_GEMFILE']) =~ /libraries/
10
10
  # Load all of the test workers
11
- pattern = File.join(File.dirname(__FILE__), '../../test/jobs/', '*.rb')
11
+ pattern = File.join(File.dirname(__FILE__), '../../test/jobs/**/', '*.rb')
12
12
  Dir.glob(pattern) do |f|
13
- TV.logger.debug "Loading test job file: #{f}"
13
+ TV.logger.debug "Loading test job file: #{File.basename(f)}"
14
14
  require f
15
15
  end
16
16
  end
@@ -8,7 +8,7 @@ module TraceView
8
8
  module Version
9
9
  MAJOR = 3
10
10
  MINOR = 3
11
- PATCH = 1
11
+ PATCH = 3
12
12
  BUILD = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -0,0 +1,128 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ require 'minitest_helper'
5
+ require_relative "../jobs/delayed_job/remote_call_worker_job"
6
+ require_relative "../jobs/delayed_job/db_worker_job"
7
+ require_relative "../jobs/delayed_job/error_worker_job"
8
+
9
+ class DelayedJobClientTest < Minitest::Test
10
+ def setup
11
+ clear_all_traces
12
+ @collect_backtraces = TraceView::Config[:delayedjobclient][:collect_backtraces]
13
+ @log_args = TraceView::Config[:delayedjobclient][:log_args]
14
+ end
15
+
16
+ def teardown
17
+ TraceView::Config[:delayedjobclient][:collect_backtraces] = @collect_backtraces
18
+ TraceView::Config[:delayedjobclient][:log_args] = @log_args
19
+ end
20
+
21
+ def test_enqueue
22
+ # Queue up a job to be run
23
+ jid, _ = ::TraceView::API.start_trace(:enqueue_test) do
24
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
25
+ end
26
+
27
+ # Allow the job to be run
28
+ sleep 5
29
+
30
+ traces = get_all_traces
31
+ assert_equal 23, traces.count, "Trace count"
32
+ valid_edges?(traces)
33
+
34
+ assert_equal 'sidekiq-client', traces[1]['Layer']
35
+ assert_equal 'entry', traces[1]['Label']
36
+
37
+ assert_equal 'msgclient', traces[1]['Spec']
38
+ assert_equal 'sidekiq', traces[1]['Flavor']
39
+ assert_equal 'critical', traces[1]['Queue']
40
+ assert_equal jid, traces[1]['MsgID']
41
+ assert_equal '[1, 2, 3]', traces[1]['Args']
42
+ assert_equal "RemoteCallWorkerJob", traces[1]['JobName']
43
+ assert_equal 'false', traces[1]['Retry']
44
+ assert_equal false, traces[1].key?('Backtrace')
45
+
46
+ assert_equal 'sidekiq-client', traces[2]['Layer']
47
+ assert_equal 'exit', traces[2]['Label']
48
+ end
49
+
50
+ def test_collect_backtraces_default_value
51
+ assert_equal TV::Config[:delayedjobclient][:collect_backtraces], false, "default backtrace collection"
52
+ end
53
+
54
+ def test_log_args_default_value
55
+ assert_equal TV::Config[:delayedjobclient][:log_args], true, "log_args default "
56
+ end
57
+
58
+ def test_obey_collect_backtraces_when_false
59
+ TraceView::Config[:delayedjobclient][:collect_backtraces] = false
60
+
61
+ # Queue up a job to be run
62
+ ::TraceView::API.start_trace(:enqueue_test) do
63
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
64
+ end
65
+
66
+ # Allow the job to be run
67
+ sleep 5
68
+
69
+ traces = get_all_traces
70
+ assert_equal 23, traces.count, "Trace count"
71
+ valid_edges?(traces)
72
+ assert_equal 'sidekiq-client', traces[1]['Layer']
73
+ assert_equal false, traces[1].key?('Backtrace')
74
+ end
75
+
76
+ def test_obey_collect_backtraces_when_true
77
+ TraceView::Config[:delayedjobclient][:collect_backtraces] = true
78
+
79
+ # Queue up a job to be run
80
+ ::TraceView::API.start_trace(:enqueue_test) do
81
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
82
+ end
83
+
84
+ # Allow the job to be run
85
+ sleep 5
86
+
87
+ traces = get_all_traces
88
+ assert_equal 23, traces.count, "Trace count"
89
+ valid_edges?(traces)
90
+ assert_equal 'sidekiq-client', traces[1]['Layer']
91
+ assert_equal true, traces[1].key?('Backtrace')
92
+ end
93
+
94
+ def test_obey_log_args_when_false
95
+ TraceView::Config[:delayedjobclient][:log_args] = false
96
+
97
+ # Queue up a job to be run
98
+ ::TraceView::API.start_trace(:enqueue_test) do
99
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
100
+ end
101
+
102
+ # Allow the job to be run
103
+ sleep 5
104
+
105
+ traces = get_all_traces
106
+ assert_equal 23, traces.count, "Trace count"
107
+ valid_edges?(traces)
108
+ assert_equal false, traces[1].key?('Args')
109
+ end
110
+
111
+ def test_obey_log_args_when_true
112
+ TraceView::Config[:delayedjobclient][:log_args] = true
113
+
114
+ # Queue up a job to be run
115
+ ::TraceView::API.start_trace(:enqueue_test) do
116
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
117
+ end
118
+
119
+ # Allow the job to be run
120
+ sleep 5
121
+
122
+ traces = get_all_traces
123
+ assert_equal 23, traces.count, "Trace count"
124
+ valid_edges?(traces)
125
+ assert_equal true, traces[1].key?('Args')
126
+ assert_equal '[1, 2, 3]', traces[1]['Args']
127
+ end
128
+ end
@@ -0,0 +1,177 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ require 'minitest_helper'
5
+ require_relative "../jobs/delayed_job/remote_call_worker_job"
6
+ require_relative "../jobs/delayed_job/db_worker_job"
7
+ require_relative "../jobs/delayed_job/error_worker_job"
8
+
9
+ class DelayedJobWorkerTest < Minitest::Test
10
+ def setup
11
+ clear_all_traces
12
+ @collect_backtraces = TraceView::Config[:delayedjobworker][:collect_backtraces]
13
+ @log_args = TraceView::Config[:delayedjobworker][:log_args]
14
+ end
15
+
16
+ def teardown
17
+ TraceView::Config[:delayedjobworker][:collect_backtraces] = @collect_backtraces
18
+ TraceView::Config[:delayedjobworker][:log_args] = @log_args
19
+ end
20
+
21
+ def test_reports_version_init
22
+ init_kvs = ::TraceView::Util.build_init_report
23
+ assert init_kvs.key?('Ruby.Sidekiq.Version')
24
+ assert_equal "Sidekiq-#{::Sidekiq::VERSION}", init_kvs['Ruby.Sidekiq.Version']
25
+ end
26
+
27
+ def test_job_run
28
+ # Queue up a job to be run
29
+ jid = Sidekiq::Client.push('queue' => 'critical', 'class' => RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
30
+
31
+ # Allow the job to be run
32
+ sleep 5
33
+
34
+ traces = get_all_traces
35
+ assert_equal 17, traces.count, "Trace count"
36
+ validate_outer_layers(traces, "sidekiq-worker")
37
+ valid_edges?(traces)
38
+
39
+ # Validate entry layer KVs
40
+ assert_equal 'always_sampled', traces[0]['TraceOrigin'], "is always_sampled"
41
+ assert_equal true, traces[0].key?('SampleRate'), "has SampleRate KV"
42
+ assert_equal true, traces[0].key?('SampleSource'), "has SampleSource KV"
43
+
44
+ # Validate Webserver Spec KVs
45
+ assert_equal Socket.gethostname, traces[0]['HTTP-Host']
46
+ assert_equal "Sidekiq_critical", traces[0]['Controller']
47
+ assert_equal "RemoteCallWorkerJob", traces[0]['Action']
48
+ assert_equal "/sidekiq/critical/RemoteCallWorkerJob", traces[0]['URL']
49
+
50
+ # Validate Job Spec KVs
51
+ assert_equal "job", traces[0]['Spec']
52
+ assert_equal 'sidekiq', traces[0]['Flavor']
53
+ assert_equal "RemoteCallWorkerJob", traces[0]['JobName']
54
+ assert_equal jid, traces[0]['MsgID']
55
+ assert_equal "critical", traces[0]['Queue']
56
+ assert_equal "[1, 2, 3]", traces[0]['Args']
57
+ assert_equal "false", traces[0]['Retry']
58
+
59
+ assert_equal false, traces[0].key?('Backtrace')
60
+ assert_equal "net-http", traces[4]['Layer']
61
+ assert_equal "entry", traces[4]['Label']
62
+ assert_equal "memcache", traces[15]['Layer']
63
+ end
64
+
65
+ def test_jobs_with_errors
66
+ # Queue up a job to be run
67
+ jid = Sidekiq::Client.push('queue' => 'critical', 'class' => ErrorWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
68
+
69
+ # Allow the job to be run
70
+ sleep 5
71
+
72
+ traces = get_all_traces
73
+ assert_equal 3, traces.count, "Trace count"
74
+ validate_outer_layers(traces, "sidekiq-worker")
75
+ valid_edges?(traces)
76
+
77
+ # Validate Webserver Spec KVs
78
+ assert_equal Socket.gethostname, traces[0]['HTTP-Host']
79
+ assert_equal "Sidekiq_critical", traces[0]['Controller']
80
+ assert_equal "ErrorWorkerJob", traces[0]['Action']
81
+ assert_equal "/sidekiq/critical/ErrorWorkerJob", traces[0]['URL']
82
+
83
+ # Validate Job Spec KVs
84
+ assert_equal "job", traces[0]['Spec']
85
+ assert_equal 'sidekiq', traces[0]['Flavor']
86
+ assert_equal "ErrorWorkerJob", traces[0]['JobName']
87
+ assert_equal jid, traces[0]['MsgID']
88
+ assert_equal "critical", traces[0]['Queue']
89
+ assert_equal "[1, 2, 3]", traces[0]['Args']
90
+ assert_equal "false", traces[0]['Retry']
91
+
92
+ assert_equal traces[1]['Layer'], 'sidekiq-worker'
93
+ assert_equal traces[1]['Label'], 'error'
94
+ assert_equal traces[1]['ErrorClass'], "RuntimeError"
95
+ assert traces[1].key?('ErrorMsg')
96
+ assert traces[1].key?('Backtrace')
97
+ end
98
+
99
+ def test_collect_backtraces_default_value
100
+ assert_equal TV::Config[:delayedjobworker][:collect_backtraces], false, "default backtrace collection"
101
+ end
102
+
103
+ def test_log_args_default_value
104
+ assert_equal TV::Config[:delayedjobworker][:log_args], true, "log_args default "
105
+ end
106
+
107
+ def test_obey_collect_backtraces_when_false
108
+ TraceView::Config[:delayedjobworker][:collect_backtraces] = false
109
+
110
+ # Queue up a job to be run
111
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
112
+
113
+ # Allow the job to be run
114
+ sleep 5
115
+
116
+ traces = get_all_traces
117
+ assert_equal 17, traces.count, "Trace count"
118
+ valid_edges?(traces)
119
+ assert_equal 'sidekiq-worker', traces[0]['Layer']
120
+ assert_equal false, traces[0].key?('Backtrace')
121
+ end
122
+
123
+ def test_obey_collect_backtraces_when_true
124
+ # FIXME: This can't be tested with the current Sidekiq minitest integration (e.g. already booted
125
+ # sidekiq in a different process)
126
+ skip
127
+
128
+ TraceView::Config[:delayedjobworker][:collect_backtraces] = true
129
+
130
+ # Queue up a job to be run
131
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
132
+
133
+ # Allow the job to be run
134
+ sleep 5
135
+
136
+ traces = get_all_traces
137
+ assert_equal 17, traces.count, "Trace count"
138
+ valid_edges?(traces)
139
+ assert_equal 'sidekiq-worker', traces[0]['Layer']
140
+ assert_equal true, traces[0].key?('Backtrace')
141
+ end
142
+
143
+ def test_obey_log_args_when_false
144
+ # FIXME: This can't be tested with the current Sidekiq minitest integration (e.g. already booted
145
+ # sidekiq in a different process)
146
+ skip
147
+
148
+ TraceView::Config[:delayedjobworker][:log_args] = false
149
+
150
+ # Queue up a job to be run
151
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
152
+
153
+ # Allow the job to be run
154
+ sleep 5
155
+
156
+ traces = get_all_traces
157
+ assert_equal 17, traces.count, "Trace count"
158
+ valid_edges?(traces)
159
+ assert_equal false, traces[0].key?('Args')
160
+ end
161
+
162
+ def test_obey_log_args_when_true
163
+ TraceView::Config[:delayedjobworker][:log_args] = true
164
+
165
+ # Queue up a job to be run
166
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
167
+
168
+ # Allow the job to be run
169
+ sleep 5
170
+
171
+ traces = get_all_traces
172
+ assert_equal 17, traces.count, "Trace count"
173
+ valid_edges?(traces)
174
+ assert_equal true, traces[0].key?('Args')
175
+ assert_equal '[1, 2, 3]', traces[0]['Args']
176
+ end
177
+ end
@@ -1,65 +1,185 @@
1
1
  # Copyright (c) 2015 AppNeta, Inc.
2
2
  # All rights reserved.
3
3
 
4
- require 'minitest_helper'
4
+ if RUBY_VERSION >= '1.9.3' && !defined?(JRUBY_VERSION)
5
+ require 'minitest_helper'
6
+ require_relative "../jobs/resque/remote_call_worker_job"
7
+ require_relative "../jobs/resque/error_worker_job"
8
+
9
+ class ResqueClientTest < Minitest::Test
10
+ def setup
11
+ clear_all_traces
12
+ @collect_backtraces = TraceView::Config[:resqueclient][:collect_backtraces]
13
+ @log_args = TraceView::Config[:resqueclient][:log_args]
14
+ end
5
15
 
6
- describe "Resque" do
7
- before do
8
- clear_all_traces
16
+ def teardown
17
+ TraceView::Config[:resqueclient][:collect_backtraces] = @collect_backtraces
18
+ TraceView::Config[:resqueclient][:log_args] = @log_args
19
+ end
9
20
 
10
- # These are standard entry/exit KVs that are passed up with all moped operations
11
- @entry_kvs = {
12
- 'Layer' => 'resque',
13
- 'Label' => 'entry' }
21
+ def test_tv_methods_defined
22
+ [ :enqueue, :enqueue_to, :dequeue ].each do |m|
23
+ assert_equal true, ::Resque.method_defined?("#{m}_with_traceview")
24
+ end
14
25
 
15
- @exit_kvs = { 'Layer' => 'resque', 'Label' => 'exit' }
16
- end
26
+ assert_equal true, ::Resque::Worker.method_defined?("perform_with_traceview")
27
+ assert_equal true, ::Resque::Job.method_defined?("fail_with_traceview")
28
+ end
17
29
 
18
- it 'Stock Resque should be loaded, defined and ready' do
19
- defined?(::Resque).wont_match nil
20
- defined?(::Resque::Worker).wont_match nil
21
- defined?(::Resque::Job).wont_match nil
22
- end
30
+ def not_tracing_validation
31
+ assert_equal true, Resque.enqueue(ResqueRemoteCallWorkerJob), "not tracing; enqueue return value"
32
+ assert_equal true, Resque.enqueue(ResqueRemoteCallWorkerJob, 1, 2, "3"), "not tracing; enqueue extra params"
33
+ end
34
+
35
+ def test_enqueue
36
+ TraceView::API.start_trace('resque-client_test', '', {}) do
37
+ Resque.enqueue(ResqueRemoteCallWorkerJob)
38
+ end
39
+
40
+ traces = get_all_traces
23
41
 
24
- it 'Resque should have traceview methods defined' do
25
- [ :enqueue, :enqueue_to, :dequeue ].each do |m|
26
- ::Resque.method_defined?("#{m}_with_traceview").must_equal true
42
+ assert_equal 6, traces.count, "trace count"
43
+ validate_outer_layers(traces, 'resque-client_test')
44
+
45
+ assert_equal "resque-client", traces[1]['Layer'], "entry event layer name"
46
+ assert_equal "entry", traces[1]['Label'], "entry event label"
47
+ assert_equal "pushq", traces[1]['Spec']
48
+ assert_equal "resque", traces[1]['Flavor']
49
+ assert_equal "ResqueRemoteCallWorkerJob", traces[1]['JobName']
50
+ assert_equal "critical", traces[1]['Queue']
51
+ assert_equal "resque-client", traces[4]['Layer'], "exit event layer name"
52
+ assert_equal "exit", traces[4]['Label'], "exit event label"
27
53
  end
28
54
 
29
- ::Resque::Worker.method_defined?("perform_with_traceview").must_equal true
30
- ::Resque::Job.method_defined?("fail_with_traceview").must_equal true
31
- end
55
+ def test_dequeue
56
+ TraceView::API.start_trace('resque-client_test', '', {}) do
57
+ Resque.dequeue(ResqueRemoteCallWorkerJob, { :generate => :moped })
58
+ end
59
+
60
+ traces = get_all_traces
61
+
62
+ assert_equal 6, traces.count, "trace count"
63
+ validate_outer_layers(traces, 'resque-client_test')
32
64
 
33
- it "should trace enqueue" do
34
- skip
35
- TraceView::API.start_trace('resque-client_test', '', {}) do
36
- Resque.enqueue(TraceViewResqueJob, { :generate => :activerecord, :delay => rand(5..30).to_f })
37
- Resque.enqueue(TraceViewResqueJobThatFails)
38
- Resque.dequeue(TraceViewResqueJob, { :generate => :moped })
65
+ assert_equal "resque-client", traces[1]['Layer'], "entry event layer name"
66
+ assert_equal "entry", traces[1]['Label'], "entry event label"
67
+ assert_equal "pushq", traces[1]['Spec']
68
+ assert_equal "resque", traces[1]['Flavor']
69
+ assert_equal "ResqueRemoteCallWorkerJob", traces[1]['JobName']
70
+ assert_equal "critical", traces[1]['Queue']
71
+ assert_equal "resque-client", traces[4]['Layer'], "exit event layer name"
72
+ assert_equal "exit", traces[4]['Label'], "exit event label"
39
73
  end
40
74
 
41
- traces = get_all_traces
75
+ def test_legacy_resque_config
76
+ assert_equal true, (TraceView::Config[:resque][:enabled] = true), "set legacy resque config options don't die"
77
+ assert_equal true, (TraceView::Config[:resque][:link_workers] = true), "set legacy resque config options don't die"
78
+ end
42
79
 
43
- traces.count.must_equal 4
44
- validate_outer_layers(traces, 'resque-client_test')
80
+ def test_collect_backtraces_default_value
81
+ assert_equal TV::Config[:resqueclient][:collect_backtraces], true, "default backtrace collection"
82
+ end
45
83
 
46
- validate_event_keys(traces[1], @entry_kvs)
47
- validate_event_keys(traces[2], @exit_kvs)
48
- end
84
+ def test_log_args_default_value
85
+ assert_equal TV::Config[:resqueclient][:log_args], true, "log_args default "
86
+ end
49
87
 
50
- it "should trace dequeue" do
51
- skip
52
- TraceView::API.start_trace('resque-client_test', '', {}) do
53
- Resque.dequeue(TraceViewResqueJob, { :generate => :moped })
88
+ def test_obey_collect_backtraces_when_false
89
+ TraceView::Config[:resqueclient][:collect_backtraces] = false
90
+
91
+ # Queue up a job to be run
92
+ ::TraceView::API.start_trace('resque-client_test') do
93
+ Resque.enqueue(ResqueRemoteCallWorkerJob, [1, 2, 3])
94
+ end
95
+
96
+ traces = get_all_traces
97
+ assert_equal 6, traces.count, "trace count"
98
+ validate_outer_layers(traces, 'resque-client_test')
99
+
100
+ assert_equal false, traces[1].key?('Backtrace')
101
+
102
+ assert_equal "resque-client", traces[1]['Layer'], "entry event layer name"
103
+ assert_equal "entry", traces[1]['Label'], "entry event label"
104
+ assert_equal "pushq", traces[1]['Spec']
105
+ assert_equal "resque", traces[1]['Flavor']
106
+ assert_equal "ResqueRemoteCallWorkerJob", traces[1]['JobName']
107
+ assert_equal "critical", traces[1]['Queue']
108
+ assert_equal "resque-client", traces[4]['Layer'], "exit event layer name"
109
+ assert_equal "exit", traces[4]['Label'], "exit event label"
110
+ end
111
+
112
+ def test_obey_collect_backtraces_when_true
113
+ TraceView::Config[:resqueclient][:collect_backtraces] = true
114
+
115
+ # Queue up a job to be run
116
+ ::TraceView::API.start_trace('resque-client_test') do
117
+ Resque.enqueue(ResqueRemoteCallWorkerJob, [1, 2, 3])
118
+ end
119
+
120
+ traces = get_all_traces
121
+ assert_equal 6, traces.count, "trace count"
122
+ validate_outer_layers(traces, 'resque-client_test')
123
+
124
+ assert_equal true, traces[1].key?('Backtrace')
125
+
126
+ assert_equal "resque-client", traces[1]['Layer'], "entry event layer name"
127
+ assert_equal "entry", traces[1]['Label'], "entry event label"
128
+ assert_equal "pushq", traces[1]['Spec']
129
+ assert_equal "resque", traces[1]['Flavor']
130
+ assert_equal "ResqueRemoteCallWorkerJob", traces[1]['JobName']
131
+ assert_equal "critical", traces[1]['Queue']
132
+ assert_equal "resque-client", traces[4]['Layer'], "exit event layer name"
133
+ assert_equal "exit", traces[4]['Label'], "exit event label"
54
134
  end
55
135
 
56
- traces = get_all_traces
136
+ def test_obey_log_args_when_false
137
+ TraceView::Config[:resqueclient][:log_args] = false
138
+
139
+ # Queue up a job to be run
140
+ ::TraceView::API.start_trace('resque-client_test') do
141
+ Resque.enqueue(ResqueRemoteCallWorkerJob, [1, 2, 3])
142
+ end
143
+
144
+ traces = get_all_traces
145
+ assert_equal 6, traces.count, "trace count"
146
+ validate_outer_layers(traces, 'resque-client_test')
57
147
 
58
- traces.count.must_equal 4
59
- validate_outer_layers(traces, 'resque-client_test')
148
+ assert_equal false, traces[1].key?('Args')
60
149
 
61
- validate_event_keys(traces[1], @entry_kvs)
62
- validate_event_keys(traces[2], @exit_kvs)
150
+ assert_equal "resque-client", traces[1]['Layer'], "entry event layer name"
151
+ assert_equal "entry", traces[1]['Label'], "entry event label"
152
+ assert_equal "pushq", traces[1]['Spec']
153
+ assert_equal "resque", traces[1]['Flavor']
154
+ assert_equal "ResqueRemoteCallWorkerJob", traces[1]['JobName']
155
+ assert_equal "critical", traces[1]['Queue']
156
+ assert_equal "resque-client", traces[4]['Layer'], "exit event layer name"
157
+ assert_equal "exit", traces[4]['Label'], "exit event label"
158
+ end
159
+
160
+ def test_obey_log_args_when_true
161
+ TraceView::Config[:resqueclient][:log_args] = true
162
+
163
+ # Queue up a job to be run
164
+ ::TraceView::API.start_trace('resque-client_test') do
165
+ Resque.enqueue(ResqueRemoteCallWorkerJob, 1, 2, 3)
166
+ end
167
+
168
+ traces = get_all_traces
169
+ assert_equal 6, traces.count, "trace count"
170
+ validate_outer_layers(traces, 'resque-client_test')
171
+
172
+ assert_equal true, traces[1].key?('Args')
173
+ assert_equal "[1,2,3]", traces[1]['Args']
174
+
175
+ assert_equal "resque-client", traces[1]['Layer'], "entry event layer name"
176
+ assert_equal "entry", traces[1]['Label'], "entry event label"
177
+ assert_equal "pushq", traces[1]['Spec']
178
+ assert_equal "resque", traces[1]['Flavor']
179
+ assert_equal "ResqueRemoteCallWorkerJob", traces[1]['JobName']
180
+ assert_equal "critical", traces[1]['Queue']
181
+ assert_equal "resque-client", traces[4]['Layer'], "exit event layer name"
182
+ assert_equal "exit", traces[4]['Label'], "exit event label"
183
+ end
63
184
  end
64
185
  end
65
-
@@ -1,12 +1,12 @@
1
1
  # Copyright (c) 2015 AppNeta, Inc.
2
2
  # All rights reserved.
3
3
 
4
- if RUBY_VERSION >= '2.0'
4
+ if RUBY_VERSION >= '2.0' && !defined?(JRUBY_VERSION)
5
5
  require 'minitest_helper'
6
6
  require 'sidekiq'
7
- require_relative "../jobs/remote_call_worker_job"
8
- require_relative "../jobs/db_worker_job"
9
- require_relative "../jobs/error_worker_job"
7
+ require_relative "../jobs/sidekiq/remote_call_worker_job"
8
+ require_relative "../jobs/sidekiq/db_worker_job"
9
+ require_relative "../jobs/sidekiq/error_worker_job"
10
10
 
11
11
  class SidekiqClientTest < Minitest::Test
12
12
  def setup
@@ -1,12 +1,12 @@
1
1
  # Copyright (c) 2015 AppNeta, Inc.
2
2
  # All rights reserved.
3
3
 
4
- if RUBY_VERSION >= '2.0'
4
+ if RUBY_VERSION >= '2.0' && !defined?(JRUBY_VERSION)
5
5
  require 'minitest_helper'
6
6
  require 'sidekiq'
7
- require_relative "../jobs/remote_call_worker_job"
8
- require_relative "../jobs/db_worker_job"
9
- require_relative "../jobs/error_worker_job"
7
+ require_relative "../jobs/sidekiq/remote_call_worker_job"
8
+ require_relative "../jobs/sidekiq/db_worker_job"
9
+ require_relative "../jobs/sidekiq/error_worker_job"
10
10
 
11
11
  class SidekiqWorkerTest < Minitest::Test
12
12
  def setup
@@ -0,0 +1,29 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ class ResqueDBWorkerJob
5
+ @queue = :normal
6
+
7
+ def self.perform(*args)
8
+ return unless defined?(::Sequel) && !defined?(JRUBY_VERSION)
9
+
10
+ if ENV.key?('TRAVIS_MYSQL_PASS')
11
+ @db = Sequel.connect("mysql2://root:#{ENV['TRAVIS_MYSQL_PASS']}@127.0.0.1:3306/travis_ci_test")
12
+ else
13
+ @db = Sequel.connect('mysql2://root@127.0.0.1:3306/travis_ci_test')
14
+ end
15
+
16
+ unless @db.table_exists?(:items)
17
+ @db.create_table :items do
18
+ primary_key :id
19
+ String :name
20
+ Float :price
21
+ end
22
+ end
23
+
24
+ @db.run('select 1')
25
+
26
+ items = @db[:items]
27
+ items.count
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ class ResqueErrorWorkerJob
5
+ @queue = :critical
6
+
7
+ def self.perform(*args)
8
+ raise "This is a worker error yeah!"
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ class ResqueRemoteCallWorkerJob
5
+ @queue = :critical
6
+
7
+ def self.perform(*args)
8
+ # Make some random Dalli (memcache) calls and top it
9
+ # off with an excon call to the background rack webserver.
10
+ @dc = Dalli::Client.new
11
+ @dc.get(rand(10).to_s)
12
+ uri = URI('http://gameface.in/gamers')
13
+ http = Net::HTTP.new(uri.host, uri.port)
14
+ request = Net::HTTP::Get.new(uri.request_uri)
15
+ http.request(request)
16
+ @dc.get(rand(10).to_s)
17
+ @dc.get(rand(10).to_s)
18
+ @dc.get_multi([:one, :two, :three, :four, :five, :six])
19
+ end
20
+ end
@@ -62,8 +62,12 @@ when /rails3/
62
62
  when /frameworks/
63
63
  when /libraries/
64
64
  if RUBY_VERSION >= '2.0'
65
- # Background Sidekiq thread
66
- require './test/servers/sidekiq.rb'
65
+ # Load Sidekiq if TEST isn't defined or if it is, it calls
66
+ # out the sidekiq tests
67
+ if !ENV.key?('TEST') || ENV['TEST'] =~ /sidekiq/
68
+ # Background Sidekiq thread
69
+ require './test/servers/sidekiq.rb'
70
+ end
67
71
  end
68
72
  end
69
73
 
@@ -218,4 +222,3 @@ class MiniTest::Spec
218
222
  Rack::Lint.new(@app)
219
223
  end
220
224
  end
221
-
@@ -25,11 +25,3 @@ end
25
25
 
26
26
  # Allow Sidekiq to boot up
27
27
  sleep 10
28
-
29
- # Add a hook to shutdown sidekiq after Minitest finished running
30
- Minitest.after_run {
31
- TraceView.logger.warn "[traceview/servers] Shutting down Sidekiq."
32
- pid = File.read("/tmp/sidekiq_#{Process.pid}.pid").chomp
33
- Process.kill(:TERM, pid.to_i)
34
- File.unlink "/tmp/sidekiq_#{Process.pid}.pid"
35
- }
@@ -5,9 +5,9 @@ ENV['BUNDLE_GEMFILE'] = Dir.pwd + "/gemfiles/libraries.gemfile"
5
5
 
6
6
  require 'rubygems'
7
7
  require 'bundler/setup'
8
- require_relative '../jobs/db_worker_job'
9
- require_relative '../jobs/remote_call_worker_job'
10
- require_relative '../jobs/error_worker_job'
8
+ require_relative '../jobs/sidekiq/db_worker_job'
9
+ require_relative '../jobs/sidekiq/remote_call_worker_job'
10
+ require_relative '../jobs/sidekiq/error_worker_job'
11
11
 
12
12
  ENV["RACK_ENV"] = "test"
13
13
  ENV["TRACEVIEW_GEM_TEST"] = "true"
@@ -30,7 +30,7 @@ describe "TraceView::Config" do
30
30
  instrumentation = TraceView::Config.instrumentation
31
31
 
32
32
  # Verify the number of individual instrumentations
33
- instrumentation.count.must_equal 24
33
+ instrumentation.count.must_equal 25
34
34
 
35
35
  TraceView::Config[:action_controller][:enabled].must_equal true
36
36
  TraceView::Config[:action_view][:enabled].must_equal true
@@ -50,7 +50,8 @@ describe "TraceView::Config" do
50
50
  TraceView::Config[:moped][:enabled].must_equal true
51
51
  TraceView::Config[:rack][:enabled].must_equal true
52
52
  TraceView::Config[:redis][:enabled].must_equal true
53
- TraceView::Config[:resque][:enabled].must_equal true
53
+ TraceView::Config[:resqueclient][:enabled].must_equal true
54
+ TraceView::Config[:resqueworker][:enabled].must_equal true
54
55
  TraceView::Config[:rest_client][:enabled].must_equal true
55
56
  TraceView::Config[:sequel][:enabled].must_equal true
56
57
  TraceView::Config[:sidekiqclient][:enabled].must_equal true
@@ -75,14 +76,14 @@ describe "TraceView::Config" do
75
76
  TraceView::Config[:moped][:log_args].must_equal true
76
77
  TraceView::Config[:rack][:log_args].must_equal true
77
78
  TraceView::Config[:redis][:log_args].must_equal true
78
- TraceView::Config[:resque][:log_args].must_equal true
79
+ TraceView::Config[:resqueclient][:log_args].must_equal true
80
+ TraceView::Config[:resqueworker][:log_args].must_equal true
79
81
  TraceView::Config[:rest_client][:log_args].must_equal true
80
82
  TraceView::Config[:sequel][:log_args].must_equal true
81
83
  TraceView::Config[:sidekiqclient][:log_args].must_equal true
82
84
  TraceView::Config[:sidekiqworker][:log_args].must_equal true
83
85
  TraceView::Config[:typhoeus][:log_args].must_equal true
84
86
 
85
- TraceView::Config[:resque][:link_workers].must_equal false
86
87
  TraceView::Config[:blacklist].is_a?(Array).must_equal true
87
88
 
88
89
  TraceView::Config[:dnt_regexp].must_equal "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|ttf|woff|svg|less)$"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traceview
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.3.3
5
5
  platform: java
6
6
  authors:
7
7
  - Peter Giacomo Lombardo
@@ -9,18 +9,18 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-21 00:00:00.000000000 Z
12
+ date: 2015-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
16
  version_requirements: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  requirement: !ruby/object:Gem::Requirement
22
22
  requirements:
23
- - - '>='
23
+ - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: '0'
26
26
  prerelease: false
@@ -29,12 +29,12 @@ dependencies:
29
29
  name: rake
30
30
  version_requirements: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  prerelease: false
@@ -46,9 +46,9 @@ extensions: []
46
46
  extra_rdoc_files:
47
47
  - LICENSE
48
48
  files:
49
- - .gitignore
50
- - .rubocop.yml
51
- - .travis.yml
49
+ - ".gitignore"
50
+ - ".rubocop.yml"
51
+ - ".travis.yml"
52
52
  - CHANGELOG.md
53
53
  - CONFIG.md
54
54
  - Gemfile
@@ -163,6 +163,8 @@ files:
163
163
  - test/instrumentation/cassandra_test.rb
164
164
  - test/instrumentation/curb_test.rb
165
165
  - test/instrumentation/dalli_test.rb
166
+ - test/instrumentation/delayed_job-client_test.rb
167
+ - test/instrumentation/delayed_job-worker_test.rb
166
168
  - test/instrumentation/em_http_request_test.rb
167
169
  - test/instrumentation/excon_test.rb
168
170
  - test/instrumentation/faraday_test.rb
@@ -188,9 +190,12 @@ files:
188
190
  - test/instrumentation/sidekiq-client_test.rb
189
191
  - test/instrumentation/sidekiq-worker_test.rb
190
192
  - test/instrumentation/typhoeus_test.rb
191
- - test/jobs/db_worker_job.rb
192
- - test/jobs/error_worker_job.rb
193
- - test/jobs/remote_call_worker_job.rb
193
+ - test/jobs/resque/db_worker_job.rb
194
+ - test/jobs/resque/error_worker_job.rb
195
+ - test/jobs/resque/remote_call_worker_job.rb
196
+ - test/jobs/sidekiq/db_worker_job.rb
197
+ - test/jobs/sidekiq/error_worker_job.rb
198
+ - test/jobs/sidekiq/remote_call_worker_job.rb
194
199
  - test/minitest_helper.rb
195
200
  - test/profiling/legacy_method_profiling_test.rb
196
201
  - test/profiling/method_profiling_test.rb
@@ -220,12 +225,12 @@ require_paths:
220
225
  - lib
221
226
  required_ruby_version: !ruby/object:Gem::Requirement
222
227
  requirements:
223
- - - '>='
228
+ - - ">="
224
229
  - !ruby/object:Gem::Version
225
230
  version: 1.8.6
226
231
  required_rubygems_version: !ruby/object:Gem::Requirement
227
232
  requirements:
228
- - - '>='
233
+ - - ">="
229
234
  - !ruby/object:Gem::Version
230
235
  version: '0'
231
236
  requirements: []
@@ -243,6 +248,7 @@ test_files:
243
248
  - test/servers/rackapp_8101.rb
244
249
  - test/instrumentation/excon_test.rb
245
250
  - test/instrumentation/sequel_pg_test.rb
251
+ - test/instrumentation/delayed_job-worker_test.rb
246
252
  - test/instrumentation/moped_test.rb
247
253
  - test/instrumentation/httpclient_test.rb
248
254
  - test/instrumentation/sequel_mysql_test.rb
@@ -254,6 +260,7 @@ test_files:
254
260
  - test/instrumentation/cassandra_test.rb
255
261
  - test/instrumentation/redis_strings_test.rb
256
262
  - test/instrumentation/typhoeus_test.rb
263
+ - test/instrumentation/delayed_job-client_test.rb
257
264
  - test/instrumentation/sequel_mysql2_test.rb
258
265
  - test/instrumentation/sidekiq-worker_test.rb
259
266
  - test/instrumentation/redis_misc_test.rb
@@ -289,6 +296,9 @@ test_files:
289
296
  - test/support/liboboe_settings_test.rb
290
297
  - test/support/backcompat_test.rb
291
298
  - test/support/xtrace_test.rb
292
- - test/jobs/remote_call_worker_job.rb
293
- - test/jobs/error_worker_job.rb
294
- - test/jobs/db_worker_job.rb
299
+ - test/jobs/sidekiq/remote_call_worker_job.rb
300
+ - test/jobs/sidekiq/error_worker_job.rb
301
+ - test/jobs/sidekiq/db_worker_job.rb
302
+ - test/jobs/resque/remote_call_worker_job.rb
303
+ - test/jobs/resque/error_worker_job.rb
304
+ - test/jobs/resque/db_worker_job.rb