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 +4 -4
- data/README.md +4 -0
- data/lib/sidekiq/skylight/server_middleware.rb +10 -3
- data/lib/sidekiq/skylight/version.rb +1 -1
- data/spec/sidekiq/skylight/server_middleware_spec.rb +28 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2f0ec4578edffc9fc43d5df36444c00276bc034
|
4
|
+
data.tar.gz: e0c93d6fe050b749dc287ec499c2475af04fe123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
7
|
-
|
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("#{
|
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
|
@@ -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,
|
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,
|
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,
|
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.
|
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-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|