sidekiq-skylight 0.1.0 → 0.2.0

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: 8e2c60a848b24d3651ca7f79732057f783341c1e
4
- data.tar.gz: acf95b402036e11b68a1216f8775fb7018e359c5
3
+ metadata.gz: d2f0ec4578edffc9fc43d5df36444c00276bc034
4
+ data.tar.gz: e0c93d6fe050b749dc287ec499c2475af04fe123
5
5
  SHA512:
6
- metadata.gz: 100a2d39ce801249bfad8327b181e8a23c1ea2ee4a56e6ffcf392364b6a9739420551eb39b0a2d66f6bae225b14aa1132bf0b4d2bbdf365215a0aecf306f9b45
7
- data.tar.gz: 34292932066fd99422bb8ad14591481503d0b6a36e74b906a59e3e7d1971d4a6ad709cad15404b15ea17e2927d13e0c06e357e08e7a35106dbc8f1f3a320eb04
6
+ metadata.gz: c1f0b59e037b2260385b354a301f4909d9067c5b61a69ab208f6e9a4cd446f226ff92a2a506619e073b77f88e064673694de906736b541a60126115b70f249f3
7
+ data.tar.gz: 212a5c9e276053772bed67d1978815632dd22a7359e97ca7a0ed2fc461f66825b8f41df90e939a60c9ca8335fef10ea1207860e7708405d234b4362bd124b3e6
data/README.md CHANGED
@@ -33,6 +33,10 @@ end
33
33
 
34
34
  Any workers with the class names you specify will be ignored from any Skylight tracing.
35
35
 
36
+ ## ActiveJob
37
+
38
+ If you use Sidekiq as a backend to ActiveJob, your ActiveJob name will be passed to Skylight.
39
+
36
40
  ## Usage
37
41
 
38
42
  Make sure you've setup skylight.io for your project already. Everything else should be automatic.
@@ -3,17 +3,24 @@ require 'skylight'
3
3
  module Sidekiq
4
4
  module Skylight
5
5
  class ServerMiddleware
6
- def call(worker, _job, _queue)
7
- if config.blacklisted_workers.include?(worker.class.name)
6
+ def call(worker, job, _queue)
7
+ name = expand_worker_name(worker, job)
8
+ if config.blacklisted_workers.include?(name)
8
9
  yield
9
10
  else
10
- ::Skylight.trace("#{worker.class}#perform", 'app.sidekiq.worker', 'process', &Proc.new)
11
+ ::Skylight.trace("#{name}#perform", 'app.sidekiq.worker', 'process', &Proc.new)
11
12
  end
12
13
  end
13
14
 
14
15
  def config
15
16
  Sidekiq::Skylight.config
16
17
  end
18
+
19
+ private
20
+
21
+ def expand_worker_name(worker, job)
22
+ job['wrapped'] || worker.class.name
23
+ end
17
24
  end
18
25
  end
19
26
  end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Skylight
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -11,7 +11,7 @@ describe Sidekiq::Skylight::ServerMiddleware do
11
11
  block.call
12
12
  end
13
13
 
14
- expect{|probe| middleware.call(FakeWorker.new, double(:job), double(:queue), &probe)}.to yield_control
14
+ expect{|probe| middleware.call(FakeWorker.new, {}, double(:queue), &probe)}.to yield_control
15
15
  end
16
16
 
17
17
  context 'with blacklisted workers' do
@@ -27,7 +27,7 @@ describe Sidekiq::Skylight::ServerMiddleware do
27
27
  it 'does not instrument a blacklisted worker' do
28
28
  expect(::Skylight).to_not receive(:trace)
29
29
 
30
- expect{|probe| middleware.call(BlacklistedWorker.new, double(:job), double(:queue), &probe)}.to yield_control
30
+ expect{|probe| middleware.call(BlacklistedWorker.new, {}, double(:queue), &probe)}.to yield_control
31
31
  end
32
32
 
33
33
  it 'still instruments non-blacklisted workers' do
@@ -35,7 +35,32 @@ describe Sidekiq::Skylight::ServerMiddleware do
35
35
  block.call
36
36
  end
37
37
 
38
- expect{|probe| middleware.call(FakeWorker.new, double(:job), double(:queue), &probe)}.to yield_control
38
+ expect{|probe| middleware.call(FakeWorker.new, {}, double(:queue), &probe)}.to yield_control
39
+ end
40
+ end
41
+
42
+ context 'with a wrapped job' do
43
+ around(:each) do |example|
44
+ previous_blacklisted = Sidekiq::Skylight.config.blacklisted_workers
45
+ Sidekiq::Skylight.config.blacklisted_workers = %w(BlacklistedWrappedWorker)
46
+
47
+ example.run
48
+
49
+ Sidekiq::Skylight.config.blacklisted_workers = previous_blacklisted
50
+ end
51
+
52
+ it 'does not instrument a blacklisted worker' do
53
+ expect(::Skylight).to_not receive(:trace)
54
+
55
+ expect{|probe| middleware.call(FakeWorker.new, {'wrapped' => 'BlacklistedWrappedWorker'}, double(:queue), &probe)}.to yield_control
56
+ end
57
+
58
+ it 'still instruments non-blacklisted workers' do
59
+ expect(::Skylight).to receive(:trace).with('WrappedWorker#perform', 'app.sidekiq.worker', 'process') do |&block|
60
+ block.call
61
+ end
62
+
63
+ expect{|probe| middleware.call(FakeWorker.new, {'wrapped' => 'WrappedWorker'}, double(:queue), &probe)}.to yield_control
39
64
  end
40
65
  end
41
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Madsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-16 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq