sidekiq-skylight 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +98 -0
- data/README.md +13 -0
- data/Rakefile +3 -4
- data/lib/sidekiq/skylight.rb +1 -0
- data/lib/sidekiq/skylight/configuration.rb +19 -0
- data/lib/sidekiq/skylight/server_middleware.rb +8 -2
- data/lib/sidekiq/skylight/version.rb +1 -1
- data/sidekiq-skylight.gemspec +12 -12
- data/spec/sidekiq/skylight/server_middleware_spec.rb +29 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e2c60a848b24d3651ca7f79732057f783341c1e
|
4
|
+
data.tar.gz: acf95b402036e11b68a1216f8775fb7018e359c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 100a2d39ce801249bfad8327b181e8a23c1ea2ee4a56e6ffcf392364b6a9739420551eb39b0a2d66f6bae225b14aa1132bf0b4d2bbdf365215a0aecf306f9b45
|
7
|
+
data.tar.gz: 34292932066fd99422bb8ad14591481503d0b6a36e74b906a59e3e7d1971d4a6ad709cad15404b15ea17e2927d13e0c06e357e08e7a35106dbc8f1f3a320eb04
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Common configuration.
|
2
|
+
AllCops:
|
3
|
+
# Include gemspec and Rakefile
|
4
|
+
Include:
|
5
|
+
- '**/*.gemspec'
|
6
|
+
- '**/Rakefile'
|
7
|
+
- '**/*.rake'
|
8
|
+
- '**/Gemfile'
|
9
|
+
Exclude:
|
10
|
+
- 'vendor/**'
|
11
|
+
- 'spec/fixtures/**'
|
12
|
+
- 'bin/**'
|
13
|
+
RunRailsCops: true
|
14
|
+
|
15
|
+
# Indent private/protected/public as deep as method definitions
|
16
|
+
AccessModifierIndentation:
|
17
|
+
EnforcedStyle: outdent
|
18
|
+
SupportedStyles:
|
19
|
+
- outdent
|
20
|
+
- indent
|
21
|
+
|
22
|
+
# Indentation of `when`.
|
23
|
+
CaseIndentation:
|
24
|
+
IndentWhenRelativeTo: end
|
25
|
+
SupportedStyles:
|
26
|
+
- case
|
27
|
+
- end
|
28
|
+
IndentOneStep: false
|
29
|
+
|
30
|
+
ClassLength:
|
31
|
+
CountComments: false # count full line comments?
|
32
|
+
Max: 200
|
33
|
+
|
34
|
+
# Align ends correctly.
|
35
|
+
EndAlignment:
|
36
|
+
# The value `keyword` means that `end` should be aligned with the matching
|
37
|
+
# keyword (if, while, etc.).
|
38
|
+
# The value `variable` means that in assignments, `end` should be aligned
|
39
|
+
# with the start of the variable on the left hand side of `=`. In all other
|
40
|
+
# situations, `end` should still be aligned with the keyword.
|
41
|
+
AlignWith: variable
|
42
|
+
SupportedStyles:
|
43
|
+
- keyword
|
44
|
+
- variable
|
45
|
+
|
46
|
+
# Built-in global variables are allowed by default.
|
47
|
+
GlobalVars:
|
48
|
+
AllowedVariables: ['$1', '$2', '$3', '$4', '$5', '$6']
|
49
|
+
|
50
|
+
LineLength:
|
51
|
+
Max: 120
|
52
|
+
|
53
|
+
MethodLength:
|
54
|
+
CountComments: false # count full line comments?
|
55
|
+
Max: 20
|
56
|
+
|
57
|
+
NumericLiterals:
|
58
|
+
MinDigits: 10
|
59
|
+
|
60
|
+
SignalException:
|
61
|
+
EnforcedStyle: only_raise
|
62
|
+
SupportedStyles:
|
63
|
+
- only_raise
|
64
|
+
- only_fail
|
65
|
+
- semantic
|
66
|
+
|
67
|
+
SpaceBeforeBlockBraces:
|
68
|
+
EnforcedStyle: no_space
|
69
|
+
SupportedStyles:
|
70
|
+
- space
|
71
|
+
- no_space
|
72
|
+
|
73
|
+
SpaceInsideBlockBraces:
|
74
|
+
EnforcedStyle: no_space
|
75
|
+
SupportedStyles:
|
76
|
+
- space
|
77
|
+
- no_space
|
78
|
+
# Valid values are: space, no_space
|
79
|
+
EnforcedStyleForEmptyBraces: no_space
|
80
|
+
# Space between { and |. Overrides EnforcedStyle if there is a conflict.
|
81
|
+
SpaceBeforeBlockParameters: false
|
82
|
+
|
83
|
+
SpaceInsideHashLiteralBraces:
|
84
|
+
EnforcedStyle: no_space
|
85
|
+
EnforcedStyleForEmptyBraces: no_space
|
86
|
+
SupportedStyles:
|
87
|
+
- space
|
88
|
+
- no_space
|
89
|
+
|
90
|
+
# Checks whether the source file has a utf-8 encoding comment or not
|
91
|
+
Encoding:
|
92
|
+
EnforcedStyle: when_needed
|
93
|
+
SupportedStyles:
|
94
|
+
- when_needed
|
95
|
+
- always
|
96
|
+
|
97
|
+
WordArray:
|
98
|
+
MinSize: 0
|
data/README.md
CHANGED
@@ -20,6 +20,19 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install sidekiq-skylight
|
22
22
|
|
23
|
+
## Blacklisted Jobs
|
24
|
+
|
25
|
+
If there's a job that you don't want to be instrumented via Skylight, you can
|
26
|
+
use the `blacklisted_workers` config option like so:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
Sidekiq::Skylight.configure do |config|
|
30
|
+
config.blacklisted_workers = ['BlacklistedWorker']
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
Any workers with the class names you specify will be ignored from any Skylight tracing.
|
35
|
+
|
23
36
|
## Usage
|
24
37
|
|
25
38
|
Make sure you've setup skylight.io for your project already. Everything else should be automatic.
|
data/Rakefile
CHANGED
data/lib/sidekiq/skylight.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Sidekiq
|
2
|
+
module Skylight
|
3
|
+
class Configuration
|
4
|
+
attr_accessor :blacklisted_workers
|
5
|
+
|
6
|
+
def blacklisted_workers
|
7
|
+
@blacklisted_workers ||= []
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.config
|
12
|
+
@configuration ||= Configuration.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configure
|
16
|
+
yield config
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,11 +3,17 @@ 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
|
+
if config.blacklisted_workers.include?(worker.class.name)
|
8
8
|
yield
|
9
|
+
else
|
10
|
+
::Skylight.trace("#{worker.class}#perform", 'app.sidekiq.worker', 'process', &Proc.new)
|
9
11
|
end
|
10
12
|
end
|
13
|
+
|
14
|
+
def config
|
15
|
+
Sidekiq::Skylight.config
|
16
|
+
end
|
11
17
|
end
|
12
18
|
end
|
13
19
|
end
|
data/sidekiq-skylight.gemspec
CHANGED
@@ -4,23 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'sidekiq/skylight/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'sidekiq-skylight'
|
8
8
|
spec.version = Sidekiq::Skylight::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Allen Madsen']
|
10
|
+
spec.email = ['blatyo@gmail.com']
|
11
|
+
spec.summary = 'Middleware for instrumenting Sidekiq with Skylight.io'
|
12
|
+
spec.description = 'Middleware for instrumenting Sidekiq with Skylight.io. Automatically configured when required.'
|
13
|
+
spec.homepage = 'https://github.com/lintci/sidekiq-skylight'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/})
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}){|f| File.basename(f)}
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_runtime_dependency 'sidekiq', '>= 3.3.0'
|
22
22
|
spec.add_runtime_dependency 'skylight', '>= 0.5.2'
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
26
|
end
|
@@ -4,10 +4,38 @@ describe Sidekiq::Skylight::ServerMiddleware do
|
|
4
4
|
subject(:middleware){described_class.new}
|
5
5
|
|
6
6
|
FakeWorker = Class.new
|
7
|
+
BlacklistedWorker = Class.new
|
7
8
|
|
8
9
|
it 'wraps block in skylight instrument' do
|
9
|
-
expect(::Skylight).to receive(:trace).with('FakeWorker#perform', 'app.sidekiq.worker', 'process')
|
10
|
+
expect(::Skylight).to receive(:trace).with('FakeWorker#perform', 'app.sidekiq.worker', 'process') do |&block|
|
11
|
+
block.call
|
12
|
+
end
|
10
13
|
|
11
14
|
expect{|probe| middleware.call(FakeWorker.new, double(:job), double(:queue), &probe)}.to yield_control
|
12
15
|
end
|
16
|
+
|
17
|
+
context 'with blacklisted workers' do
|
18
|
+
around(:each) do |example|
|
19
|
+
previous_blacklisted = Sidekiq::Skylight.config.blacklisted_workers
|
20
|
+
Sidekiq::Skylight.config.blacklisted_workers = %w(BlacklistedWorker)
|
21
|
+
|
22
|
+
example.run
|
23
|
+
|
24
|
+
Sidekiq::Skylight.config.blacklisted_workers = previous_blacklisted
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'does not instrument a blacklisted worker' do
|
28
|
+
expect(::Skylight).to_not receive(:trace)
|
29
|
+
|
30
|
+
expect{|probe| middleware.call(BlacklistedWorker.new, double(:job), double(:queue), &probe)}.to yield_control
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'still instruments non-blacklisted workers' do
|
34
|
+
expect(::Skylight).to receive(:trace).with('FakeWorker#perform', 'app.sidekiq.worker', 'process') do |&block|
|
35
|
+
block.call
|
36
|
+
end
|
37
|
+
|
38
|
+
expect{|probe| middleware.call(FakeWorker.new, double(:job), double(:queue), &probe)}.to yield_control
|
39
|
+
end
|
40
|
+
end
|
13
41
|
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.0
|
4
|
+
version: 0.1.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-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -90,6 +90,7 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- ".gitignore"
|
92
92
|
- ".rspec"
|
93
|
+
- ".rubocop.yml"
|
93
94
|
- Gemfile
|
94
95
|
- LICENSE.txt
|
95
96
|
- README.md
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- circle.yml
|
98
99
|
- lib/sidekiq-skylight.rb
|
99
100
|
- lib/sidekiq/skylight.rb
|
101
|
+
- lib/sidekiq/skylight/configuration.rb
|
100
102
|
- lib/sidekiq/skylight/server_middleware.rb
|
101
103
|
- lib/sidekiq/skylight/version.rb
|
102
104
|
- sidekiq-skylight.gemspec
|
@@ -123,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
125
|
version: '0'
|
124
126
|
requirements: []
|
125
127
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.4.
|
128
|
+
rubygems_version: 2.4.6
|
127
129
|
signing_key:
|
128
130
|
specification_version: 4
|
129
131
|
summary: Middleware for instrumenting Sidekiq with Skylight.io
|