traceview 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,61 @@
1
+ module TraceView
2
+ class SidekiqWorker
3
+ def collect_kvs(args)
4
+ begin
5
+ # Attempt to collect up pertinent info. If we hit something unexpected,
6
+ # keep calm and instrument on.
7
+ report_kvs = {}
8
+ worker, msg, queue = args
9
+
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]
19
+
20
+ # Webserver Spec KVs
21
+ report_kvs['HTTP-Host'] = Socket.gethostname
22
+ report_kvs[:Controller] = "Sidekiq_#{queue}"
23
+ report_kvs[:Action] = msg['class']
24
+ report_kvs[:URL] = "/sidekiq/#{queue}/#{msg['class'].to_s}"
25
+ rescue => e
26
+ TraceView.logger.warn "[traceview/sidekiq] Non-fatal error capturing KVs: #{e.message}"
27
+ end
28
+ report_kvs
29
+ end
30
+
31
+ def call(*args)
32
+ # args: 0: worker, 1: msg, 2: queue
33
+ result = nil
34
+ report_kvs = collect_kvs(args)
35
+
36
+ # 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
41
+ end
42
+
43
+ result = TraceView::API.start_trace('sidekiq-worker', incoming_context, report_kvs) do
44
+ yield
45
+ end
46
+
47
+ result[0]
48
+ end
49
+ end
50
+ end
51
+
52
+ if defined?(::Sidekiq) && RUBY_VERSION >= '2.0' && TraceView::Config[:sidekiqworker][:enabled]
53
+ ::TraceView.logger.info '[traceview/loading] Instrumenting sidekiq' if TraceView::Config[:verbose]
54
+
55
+ ::Sidekiq.configure_server do |config|
56
+ config.server_middleware do |chain|
57
+ ::TraceView.logger.info '[traceview/loading] Adding Sidekiq worker middleware' if TraceView::Config[:verbose]
58
+ chain.add ::TraceView::SidekiqWorker
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,20 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ module TraceView
5
+ module Test
6
+ class << self
7
+ def load_extras
8
+ # If we're using the libraries gemfile (with sidekiq and resque)
9
+ if File.basename(ENV['BUNDLE_GEMFILE']) =~ /libraries/
10
+ # Load all of the test workers
11
+ pattern = File.join(File.dirname(__FILE__), '../../test/jobs/', '*.rb')
12
+ Dir.glob(pattern) do |f|
13
+ TV.logger.debug "Loading test job file: #{f}"
14
+ require f
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -215,6 +215,7 @@ module TraceView
215
215
  platform_info['Ruby.Redis.Version'] = "Redis-#{::Redis::VERSION}" if defined?(::Redis::VERSION)
216
216
  platform_info['Ruby.Resque.Version'] = "Resque-#{::Resque::VERSION}" if defined?(::Resque::VERSION)
217
217
  platform_info['Ruby.RestClient.Version'] = "RestClient-#{::RestClient::VERSION}" if defined?(::RestClient::VERSION)
218
+ platform_info['Ruby.Sidekiq.Version'] = "Sidekiq-#{::Sidekiq::VERSION}" if defined?(::Sidekiq::VERSION)
218
219
  platform_info['Ruby.Typhoeus.Version'] = "Typhoeus-#{::Typhoeus::VERSION}" if defined?(::Typhoeus::VERSION)
219
220
 
220
221
  # Special case since the Mongo 1.x driver doesn't embed the version number in the gem directly
@@ -7,8 +7,8 @@ module TraceView
7
7
  # traceview.gemspec during gem build process
8
8
  module Version
9
9
  MAJOR = 3
10
- MINOR = 2
11
- PATCH = 1
10
+ MINOR = 3
11
+ PATCH = 0
12
12
  BUILD = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
data/lib/traceview.rb CHANGED
@@ -57,6 +57,8 @@ begin
57
57
  # it will load all of the Ruby instrumentation
58
58
  require 'traceview/ruby'
59
59
  require 'oboe/backward_compatibility'
60
+
61
+ require 'traceview/test' if ENV['TRACEVIEW_GEM_TEST']
60
62
  rescue => e
61
63
  $stderr.puts "[traceview/error] Problem loading: #{e.inspect}"
62
64
  $stderr.puts e.backtrace
@@ -1,7 +1,7 @@
1
1
  # Copyright (c) 2015 AppNeta, Inc.
2
2
  # All rights reserved.
3
3
 
4
- if RUBY_VERSION > '1.8.7'
4
+ if RUBY_VERSION > '1.8.7' && !defined?(JRUBY_VERSION)
5
5
 
6
6
  require 'minitest_helper'
7
7
  require 'traceview/inst/rack'
@@ -0,0 +1,131 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ if RUBY_VERSION >= '2.0'
5
+ require 'minitest_helper'
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"
10
+
11
+ class SidekiqClientTest < Minitest::Test
12
+ def setup
13
+ clear_all_traces
14
+ @collect_backtraces = TraceView::Config[:sidekiqclient][:collect_backtraces]
15
+ @log_args = TraceView::Config[:sidekiqclient][:log_args]
16
+ end
17
+
18
+ def teardown
19
+ TraceView::Config[:sidekiqclient][:collect_backtraces] = @collect_backtraces
20
+ TraceView::Config[:sidekiqclient][:log_args] = @log_args
21
+ end
22
+
23
+ def test_enqueue
24
+ # Queue up a job to be run
25
+ jid, _ = ::TraceView::API.start_trace(:enqueue_test) do
26
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
27
+ end
28
+
29
+ # Allow the job to be run
30
+ sleep 5
31
+
32
+ traces = get_all_traces
33
+ assert_equal 23, traces.count, "Trace count"
34
+ valid_edges?(traces)
35
+
36
+ assert_equal 'sidekiq-client', traces[1]['Layer']
37
+ assert_equal 'entry', traces[1]['Label']
38
+
39
+ assert_equal 'msgclient', traces[1]['Spec']
40
+ assert_equal 'sidekiq', traces[1]['Flavor']
41
+ assert_equal 'critical', traces[1]['Queue']
42
+ assert_equal jid, traces[1]['MsgID']
43
+ assert_equal '[1, 2, 3]', traces[1]['Args']
44
+ assert_equal "RemoteCallWorkerJob", traces[1]['JobName']
45
+ assert_equal 'false', traces[1]['Retry']
46
+ assert_equal false, traces[1].key?('Backtrace')
47
+
48
+ assert_equal 'sidekiq-client', traces[2]['Layer']
49
+ assert_equal 'exit', traces[2]['Label']
50
+ end
51
+
52
+ def test_collect_backtraces_default_value
53
+ assert_equal TV::Config[:sidekiqclient][:collect_backtraces], false, "default backtrace collection"
54
+ end
55
+
56
+ def test_log_args_default_value
57
+ assert_equal TV::Config[:sidekiqclient][:log_args], true, "log_args default "
58
+ end
59
+
60
+ def test_obey_collect_backtraces_when_false
61
+ TraceView::Config[:sidekiqclient][:collect_backtraces] = false
62
+
63
+ # Queue up a job to be run
64
+ ::TraceView::API.start_trace(:enqueue_test) do
65
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
66
+ end
67
+
68
+ # Allow the job to be run
69
+ sleep 5
70
+
71
+ traces = get_all_traces
72
+ assert_equal 23, traces.count, "Trace count"
73
+ valid_edges?(traces)
74
+ assert_equal 'sidekiq-client', traces[1]['Layer']
75
+ assert_equal false, traces[1].key?('Backtrace')
76
+ end
77
+
78
+ def test_obey_collect_backtraces_when_true
79
+ TraceView::Config[:sidekiqclient][:collect_backtraces] = true
80
+
81
+ # Queue up a job to be run
82
+ ::TraceView::API.start_trace(:enqueue_test) do
83
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
84
+ end
85
+
86
+ # Allow the job to be run
87
+ sleep 5
88
+
89
+ traces = get_all_traces
90
+ assert_equal 23, traces.count, "Trace count"
91
+ valid_edges?(traces)
92
+ assert_equal 'sidekiq-client', traces[1]['Layer']
93
+ assert_equal true, traces[1].key?('Backtrace')
94
+ end
95
+
96
+ def test_obey_log_args_when_false
97
+ TraceView::Config[:sidekiqclient][:log_args] = false
98
+
99
+ # Queue up a job to be run
100
+ ::TraceView::API.start_trace(:enqueue_test) do
101
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
102
+ end
103
+
104
+ # Allow the job to be run
105
+ sleep 5
106
+
107
+ traces = get_all_traces
108
+ assert_equal 23, traces.count, "Trace count"
109
+ valid_edges?(traces)
110
+ assert_equal false, traces[1].key?('Args')
111
+ end
112
+
113
+ def test_obey_log_args_when_true
114
+ TraceView::Config[:sidekiqclient][:log_args] = true
115
+
116
+ # Queue up a job to be run
117
+ ::TraceView::API.start_trace(:enqueue_test) do
118
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
119
+ end
120
+
121
+ # Allow the job to be run
122
+ sleep 5
123
+
124
+ traces = get_all_traces
125
+ assert_equal 23, traces.count, "Trace count"
126
+ valid_edges?(traces)
127
+ assert_equal true, traces[1].key?('Args')
128
+ assert_equal '[1, 2, 3]', traces[1]['Args']
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,180 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ if RUBY_VERSION >= '2.0'
5
+ require 'minitest_helper'
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"
10
+
11
+ class SidekiqWorkerTest < Minitest::Test
12
+ def setup
13
+ clear_all_traces
14
+ @collect_backtraces = TraceView::Config[:sidekiqworker][:collect_backtraces]
15
+ @log_args = TraceView::Config[:sidekiqworker][:log_args]
16
+ end
17
+
18
+ def teardown
19
+ TraceView::Config[:sidekiqworker][:collect_backtraces] = @collect_backtraces
20
+ TraceView::Config[:sidekiqworker][:log_args] = @log_args
21
+ end
22
+
23
+ def test_reports_version_init
24
+ init_kvs = ::TraceView::Util.build_init_report
25
+ assert init_kvs.key?('Ruby.Sidekiq.Version')
26
+ assert_equal "Sidekiq-#{::Sidekiq::VERSION}", init_kvs['Ruby.Sidekiq.Version']
27
+ end
28
+
29
+ def test_job_run
30
+ # Queue up a job to be run
31
+ jid = Sidekiq::Client.push('queue' => 'critical', 'class' => RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
32
+
33
+ # Allow the job to be run
34
+ sleep 5
35
+
36
+ traces = get_all_traces
37
+ assert_equal 17, traces.count, "Trace count"
38
+ validate_outer_layers(traces, "sidekiq-worker")
39
+ valid_edges?(traces)
40
+
41
+ # Validate entry layer KVs
42
+ assert_equal 'always_sampled', traces[0]['TraceOrigin'], "is always_sampled"
43
+ assert_equal true, traces[0].key?('SampleRate'), "has SampleRate KV"
44
+ assert_equal true, traces[0].key?('SampleSource'), "has SampleSource KV"
45
+
46
+ # Validate Webserver Spec KVs
47
+ assert_equal Socket.gethostname, traces[0]['HTTP-Host']
48
+ assert_equal "Sidekiq_critical", traces[0]['Controller']
49
+ assert_equal "RemoteCallWorkerJob", traces[0]['Action']
50
+ assert_equal "/sidekiq/critical/RemoteCallWorkerJob", traces[0]['URL']
51
+
52
+ # Validate Job Spec KVs
53
+ assert_equal "job", traces[0]['Spec']
54
+ assert_equal 'sidekiq', traces[0]['Flavor']
55
+ assert_equal "RemoteCallWorkerJob", traces[0]['JobName']
56
+ assert_equal jid, traces[0]['MsgID']
57
+ assert_equal "critical", traces[0]['Queue']
58
+ assert_equal "[1, 2, 3]", traces[0]['Args']
59
+ assert_equal "false", traces[0]['Retry']
60
+
61
+ assert_equal false, traces[0].key?('Backtrace')
62
+ assert_equal "net-http", traces[4]['Layer']
63
+ assert_equal "entry", traces[4]['Label']
64
+ assert_equal "memcache", traces[15]['Layer']
65
+ end
66
+
67
+ def test_jobs_with_errors
68
+ # Queue up a job to be run
69
+ jid = Sidekiq::Client.push('queue' => 'critical', 'class' => ErrorWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
70
+
71
+ # Allow the job to be run
72
+ sleep 5
73
+
74
+ traces = get_all_traces
75
+ assert_equal 3, traces.count, "Trace count"
76
+ validate_outer_layers(traces, "sidekiq-worker")
77
+ valid_edges?(traces)
78
+
79
+ # Validate Webserver Spec KVs
80
+ assert_equal Socket.gethostname, traces[0]['HTTP-Host']
81
+ assert_equal "Sidekiq_critical", traces[0]['Controller']
82
+ assert_equal "ErrorWorkerJob", traces[0]['Action']
83
+ assert_equal "/sidekiq/critical/ErrorWorkerJob", traces[0]['URL']
84
+
85
+ # Validate Job Spec KVs
86
+ assert_equal "job", traces[0]['Spec']
87
+ assert_equal 'sidekiq', traces[0]['Flavor']
88
+ assert_equal "ErrorWorkerJob", traces[0]['JobName']
89
+ assert_equal jid, traces[0]['MsgID']
90
+ assert_equal "critical", traces[0]['Queue']
91
+ assert_equal "[1, 2, 3]", traces[0]['Args']
92
+ assert_equal "false", traces[0]['Retry']
93
+
94
+ assert_equal traces[1]['Layer'], 'sidekiq-worker'
95
+ assert_equal traces[1]['Label'], 'error'
96
+ assert_equal traces[1]['ErrorClass'], "RuntimeError"
97
+ assert traces[1].key?('ErrorMsg')
98
+ assert traces[1].key?('Backtrace')
99
+ end
100
+
101
+ def test_collect_backtraces_default_value
102
+ assert_equal TV::Config[:sidekiqworker][:collect_backtraces], false, "default backtrace collection"
103
+ end
104
+
105
+ def test_log_args_default_value
106
+ assert_equal TV::Config[:sidekiqworker][:log_args], true, "log_args default "
107
+ end
108
+
109
+ def test_obey_collect_backtraces_when_false
110
+ TraceView::Config[:sidekiqworker][:collect_backtraces] = false
111
+
112
+ # Queue up a job to be run
113
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
114
+
115
+ # Allow the job to be run
116
+ sleep 5
117
+
118
+ traces = get_all_traces
119
+ assert_equal 17, traces.count, "Trace count"
120
+ valid_edges?(traces)
121
+ assert_equal 'sidekiq-worker', traces[0]['Layer']
122
+ assert_equal false, traces[0].key?('Backtrace')
123
+ end
124
+
125
+ def test_obey_collect_backtraces_when_true
126
+ # FIXME: This can't be tested with the current Sidekiq minitest integration (e.g. already booted
127
+ # sidekiq in a different process)
128
+ skip
129
+
130
+ TraceView::Config[:sidekiqworker][:collect_backtraces] = true
131
+
132
+ # Queue up a job to be run
133
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
134
+
135
+ # Allow the job to be run
136
+ sleep 5
137
+
138
+ traces = get_all_traces
139
+ assert_equal 17, traces.count, "Trace count"
140
+ valid_edges?(traces)
141
+ assert_equal 'sidekiq-worker', traces[0]['Layer']
142
+ assert_equal true, traces[0].key?('Backtrace')
143
+ end
144
+
145
+ def test_obey_log_args_when_false
146
+ # FIXME: This can't be tested with the current Sidekiq minitest integration (e.g. already booted
147
+ # sidekiq in a different process)
148
+ skip
149
+
150
+ TraceView::Config[:sidekiqworker][:log_args] = false
151
+
152
+ # Queue up a job to be run
153
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
154
+
155
+ # Allow the job to be run
156
+ sleep 5
157
+
158
+ traces = get_all_traces
159
+ assert_equal 17, traces.count, "Trace count"
160
+ valid_edges?(traces)
161
+ assert_equal false, traces[0].key?('Args')
162
+ end
163
+
164
+ def test_obey_log_args_when_true
165
+ TraceView::Config[:sidekiqworker][:log_args] = true
166
+
167
+ # Queue up a job to be run
168
+ Sidekiq::Client.push('queue' => 'critical', 'class' => ::RemoteCallWorkerJob, 'args' => [1, 2, 3], 'retry' => false)
169
+
170
+ # Allow the job to be run
171
+ sleep 5
172
+
173
+ traces = get_all_traces
174
+ assert_equal 17, traces.count, "Trace count"
175
+ valid_edges?(traces)
176
+ assert_equal true, traces[0].key?('Args')
177
+ assert_equal '[1, 2, 3]', traces[0]['Args']
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,29 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ class DBWorkerJob
5
+ include Sidekiq::Worker
6
+
7
+ def 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 ErrorWorkerJob
5
+ include Sidekiq::Worker
6
+
7
+ def 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 RemoteCallWorkerJob
5
+ include Sidekiq::Worker
6
+
7
+ def 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
@@ -61,6 +61,10 @@ when /rails3/
61
61
  require "./test/servers/rails3x_8140"
62
62
  when /frameworks/
63
63
  when /libraries/
64
+ if RUBY_VERSION >= '2.0'
65
+ # Background Sidekiq thread
66
+ require './test/servers/sidekiq.rb'
67
+ end
64
68
  end
65
69
 
66
70
  ##
@@ -143,7 +147,6 @@ def valid_edges?(traces)
143
147
  traces.reverse.each do |t|
144
148
  if t.key?("Edge")
145
149
  unless has_edge?(t["Edge"], traces)
146
- require 'byebug'; debugger
147
150
  return false
148
151
  end
149
152
  end
@@ -0,0 +1,14 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ require 'minitest_helper'
5
+
6
+ class TVReporterTest < Minitest::Test
7
+ def reporter_has_start_method
8
+ assert_equal true, TV::Reporter.respond_to?(:start), "has restart method"
9
+ end
10
+
11
+ def reporter_has_restart_method
12
+ assert_equal true, TV::Reporter.respond_to?(:restart), "has start method"
13
+ end
14
+ end
@@ -0,0 +1,35 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ require 'sidekiq/cli'
5
+
6
+ TraceView.logger.info "[traceview/servers] Starting up background Sidekiq."
7
+
8
+ options = []
9
+ arguments = ""
10
+ options << ["-r", Dir.pwd + "/test/servers/sidekiq_initializer.rb"]
11
+ options << ["-q", "critical,20", "-q", "default"]
12
+ options << ["-c", "10"]
13
+ options << ["-P", "/tmp/sidekiq_#{Process.pid}.pid"]
14
+
15
+ options.flatten.each do |x|
16
+ arguments += " #{x}"
17
+ end
18
+
19
+ TraceView.logger.debug "[traceview/servers] sidekiq #{arguments}"
20
+
21
+ # Boot Sidekiq in a new thread
22
+ Thread.new do
23
+ system("OBOE_GEM_TEST=true sidekiq #{arguments}")
24
+ end
25
+
26
+ # Allow Sidekiq to boot up
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
+ }
@@ -0,0 +1,7 @@
1
+ ---
2
+ :concurrency: 2
3
+ :pidfile: tmp/pids/sidekiq.pid
4
+ :queues:
5
+ - default
6
+ - [critical, 2]
7
+ - [low, 1]
@@ -0,0 +1,22 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ ENV['BUNDLE_GEMFILE'] = Dir.pwd + "/gemfiles/libraries.gemfile"
5
+
6
+ require 'rubygems'
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'
11
+
12
+ ENV["RACK_ENV"] = "test"
13
+ ENV["TRACEVIEW_GEM_TEST"] = "true"
14
+ ENV["TRACEVIEW_GEM_VERBOSE"] = "true"
15
+
16
+ Bundler.require(:default, :test)
17
+
18
+ # Configure TraceView
19
+ TraceView::Config[:tracing_mode] = "always"
20
+ TraceView::Config[:sample_rate] = 1000000
21
+ TraceView.logger.level = Logger::DEBUG
22
+
@@ -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 22
33
+ instrumentation.count.must_equal 24
34
34
 
35
35
  TraceView::Config[:action_controller][:enabled].must_equal true
36
36
  TraceView::Config[:action_view][:enabled].must_equal true
@@ -53,6 +53,8 @@ describe "TraceView::Config" do
53
53
  TraceView::Config[:resque][:enabled].must_equal true
54
54
  TraceView::Config[:rest_client][:enabled].must_equal true
55
55
  TraceView::Config[:sequel][:enabled].must_equal true
56
+ TraceView::Config[:sidekiqclient][:enabled].must_equal true
57
+ TraceView::Config[:sidekiqworker][:enabled].must_equal true
56
58
  TraceView::Config[:typhoeus][:enabled].must_equal true
57
59
 
58
60
  TraceView::Config[:action_controller][:log_args].must_equal true
@@ -76,6 +78,8 @@ describe "TraceView::Config" do
76
78
  TraceView::Config[:resque][:log_args].must_equal true
77
79
  TraceView::Config[:rest_client][:log_args].must_equal true
78
80
  TraceView::Config[:sequel][:log_args].must_equal true
81
+ TraceView::Config[:sidekiqclient][:log_args].must_equal true
82
+ TraceView::Config[:sidekiqworker][:log_args].must_equal true
79
83
  TraceView::Config[:typhoeus][:log_args].must_equal true
80
84
 
81
85
  TraceView::Config[:resque][:link_workers].must_equal false
@@ -1,6 +1,7 @@
1
1
  # Copyright (c) 2015 AppNeta, Inc.
2
2
  # All rights reserved.
3
3
 
4
+ require 'set'
4
5
  require 'minitest_helper'
5
6
  require 'rack/test'
6
7
  require 'rack/lobster'