sidekiq-instrumental 0.2.2
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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.simplecov +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +62 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/circle.yml +17 -0
- data/lib/sidekiq/instrumental/configuration.rb +42 -0
- data/lib/sidekiq/instrumental/middleware/base.rb +37 -0
- data/lib/sidekiq/instrumental/middleware/client.rb +22 -0
- data/lib/sidekiq/instrumental/middleware/server.rb +37 -0
- data/lib/sidekiq/instrumental/version.rb +5 -0
- data/lib/sidekiq/instrumental.rb +43 -0
- data/sidekiq-instrumental.gemspec +28 -0
- data/spec/sidekiq/instrumental/configuration_spec.rb +86 -0
- data/spec/sidekiq/instrumental_spec.rb +76 -0
- data/spec/spec_helper.rb +19 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b5404945c3248c4f8e1f7ddd324a9c3920bf0589
|
4
|
+
data.tar.gz: 900b31e41aa4b0ec5668a5ff93f4a26502a6abdb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 95e05cd813fef585d22784a36cd1ab26c814be21848a7bcbd8bcd6cd44fa463cadcad20a28b682072e8f05b0d91d9b2ea741011390e2a5026a632fe17a363719
|
7
|
+
data.tar.gz: 141c86b37cd373c86dc32835906c45521ec7361f74f90863a9e2c3e63715521961dc03b0d3b3baf95bf7c4c0b5fe1e2597fb8dcfc212b73a14728da41011efb0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.simplecov
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Edward Rudd
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Sidekiq::Instrumental
|
2
|
+
|
3
|
+
sidekiq-instrumental is a simple gem to record Sidekiq queue stats into [Instrumental](https://instrumentalapp.com/).
|
4
|
+
|
5
|
+
This gem is inspired by the [librato-sidekiq](https://github.com/StatusPage/librato-sidekiq/) gem.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sidekiq-instrumental'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sidekiq-instrumental
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
After you configue Instrumental simply configure Sidekiq::Instrumental with the reference to your agent object.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
I = Instrumental::Agent.new(
|
29
|
+
ENV['INSTRUMENTAL_KEY'],
|
30
|
+
enabled: ENV['INSTRUMENTAL_KEY'].present?
|
31
|
+
)
|
32
|
+
# now tell Sidekiq::Instrumental what agent connection to use
|
33
|
+
Sidekiq::Instrumental.configure do |config|
|
34
|
+
config.instrumental_agent = I
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
## Configuration
|
39
|
+
|
40
|
+
**NOTE** Make all configuration changes through the `.configure` block.
|
41
|
+
|
42
|
+
enabled: Boolean, true by default
|
43
|
+
|
44
|
+
**instrumental_agent**: the Instrumental::Agent instance to use to submit metrics
|
45
|
+
|
46
|
+
**enabled**: Boolean, true by default
|
47
|
+
|
48
|
+
**whitelist_queues**: Array, list of queue names that will be the only ones sent to Instrumental (optional)
|
49
|
+
|
50
|
+
**blacklist_queues**: Array, list of queue names that will not be sent to Instrumental (optional)
|
51
|
+
|
52
|
+
**whitelist_classes**: Array, list of worker classes that will be the only ones sent to Instrumental (optional)
|
53
|
+
|
54
|
+
**blacklist_classes**: Array, list of worker classes that will not be sent to Instrumental (optional)
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/NetsoftHoldings/sidekiq-instrumental.
|
59
|
+
|
60
|
+
## License
|
61
|
+
|
62
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sidekiq/instrumental"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/circle.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
machine:
|
2
|
+
ruby:
|
3
|
+
version: 2.1.5
|
4
|
+
dependencies:
|
5
|
+
post:
|
6
|
+
- gem install geminabox
|
7
|
+
test:
|
8
|
+
post:
|
9
|
+
- gem build sidekiq-instrumental.gemspec
|
10
|
+
- rm -rf pkg
|
11
|
+
- mkdir -p pkg
|
12
|
+
- mv *.gem pkg
|
13
|
+
deployment:
|
14
|
+
production:
|
15
|
+
branch: production
|
16
|
+
commands:
|
17
|
+
- gem inabox -g ${HUBSTAFF_GEM_SERVER}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Sidekiq
|
2
|
+
module Instrumental
|
3
|
+
class Configuration
|
4
|
+
ARRAY_OPTIONS = [:whitelist_queues, :blacklist_queues, :whitelist_classes, :blacklist_classes]
|
5
|
+
|
6
|
+
attr_accessor :instrumental_agent
|
7
|
+
attr_accessor :enabled, *ARRAY_OPTIONS
|
8
|
+
|
9
|
+
alias_method :I, :instrumental_agent
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@instrumental_agent = nil
|
13
|
+
self.enabled = true
|
14
|
+
ARRAY_OPTIONS.each {|o| self.send("#{o}=", [])}
|
15
|
+
end
|
16
|
+
|
17
|
+
def enabled?
|
18
|
+
@enabled && !@instrumental_agent.nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
def queue_in_whitelist(queue)
|
22
|
+
whitelist_queues.nil? || whitelist_queues.empty? || whitelist_queues.include?(queue.to_s)
|
23
|
+
end
|
24
|
+
|
25
|
+
def queue_in_blacklist(queue)
|
26
|
+
blacklist_queues.include?(queue.to_s)
|
27
|
+
end
|
28
|
+
|
29
|
+
def class_in_whitelist(worker_instance)
|
30
|
+
whitelist_classes.nil? || whitelist_classes.empty? || whitelist_classes.include?(worker_instance.class.to_s)
|
31
|
+
end
|
32
|
+
|
33
|
+
def class_in_blacklist(worker_instance)
|
34
|
+
blacklist_classes.include?(worker_instance.class.to_s)
|
35
|
+
end
|
36
|
+
|
37
|
+
def allowed_to_submit(queue, worker_instance)
|
38
|
+
class_in_whitelist(worker_instance) && !class_in_blacklist(worker_instance) && queue_in_whitelist(queue) && !queue_in_blacklist(queue)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'sidekiq/api'
|
2
|
+
|
3
|
+
module Sidekiq
|
4
|
+
module Instrumental
|
5
|
+
module Middleware
|
6
|
+
class Base
|
7
|
+
attr_reader :config
|
8
|
+
|
9
|
+
def initialize(config)
|
10
|
+
@config = config
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(worker_instance, msg, queue, redis_pool = nil)
|
14
|
+
start_time = Time.now
|
15
|
+
result = yield
|
16
|
+
elapsed = (Time.now - start_time).to_f
|
17
|
+
|
18
|
+
return result unless config.enabled?
|
19
|
+
|
20
|
+
track(::Sidekiq::Stats.new, worker_instance, msg, queue, elapsed)
|
21
|
+
|
22
|
+
result
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def increment(*args)
|
28
|
+
config.I.increment *args
|
29
|
+
end
|
30
|
+
|
31
|
+
def gauge(*args)
|
32
|
+
config.I.gauge *args
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Sidekiq
|
2
|
+
module Instrumental
|
3
|
+
module Middleware
|
4
|
+
class Client < Base
|
5
|
+
|
6
|
+
def track(stats, worker_instance, msg, queue, elapsed)
|
7
|
+
|
8
|
+
increment('sidekiq.queued')
|
9
|
+
|
10
|
+
return unless config.allowed_to_submit queue, worker_instance
|
11
|
+
|
12
|
+
base_key = "sidekiq.#{queue.to_s}."
|
13
|
+
increment(base_key + 'queued')
|
14
|
+
|
15
|
+
base_key += msg['class'].underscore.gsub('/', '_') + '.'
|
16
|
+
|
17
|
+
increment(base_key + 'queued')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Sidekiq
|
2
|
+
module Instrumental
|
3
|
+
module Middleware
|
4
|
+
class Server < Base
|
5
|
+
protected
|
6
|
+
|
7
|
+
def track(stats, worker_instance, msg, queue, elapsed)
|
8
|
+
submit_general_stats(stats)
|
9
|
+
|
10
|
+
return unless config.allowed_to_submit queue, worker_instance
|
11
|
+
|
12
|
+
base_key = "sidekiq.#{queue.to_s}."
|
13
|
+
|
14
|
+
increment(base_key + 'processed')
|
15
|
+
gauge(base_key + 'time', elapsed)
|
16
|
+
gauge(base_key + 'enqueued', stats.queues[queue].to_i)
|
17
|
+
guage(base_key + 'latency', Sidekiq::Queue.new(queue.to_s).latency)
|
18
|
+
base_key += msg['class'].underscore.gsub('/', '_') + '.'
|
19
|
+
|
20
|
+
increment(base_key + 'processed')
|
21
|
+
increment(base_key + 'time', elapsed)
|
22
|
+
end
|
23
|
+
|
24
|
+
def submit_general_stats(stats)
|
25
|
+
increment("sidekiq.processed")
|
26
|
+
{
|
27
|
+
enqueued: nil,
|
28
|
+
failed: nil,
|
29
|
+
scheduled_size: 'scheduled'
|
30
|
+
}.each do |method, name|
|
31
|
+
gauge("sidekiq.#{(name || method).to_s}", stats.send(method).to_i)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "sidekiq/instrumental/version"
|
2
|
+
require 'sidekiq/instrumental/configuration'
|
3
|
+
require 'sidekiq/instrumental/middleware/base'
|
4
|
+
require 'sidekiq/instrumental/middleware/client'
|
5
|
+
require 'sidekiq/instrumental/middleware/server'
|
6
|
+
require 'sidekiq'
|
7
|
+
|
8
|
+
module Sidekiq
|
9
|
+
module Instrumental
|
10
|
+
def self.config
|
11
|
+
@config ||= Sidekiq::Instrumental::Configuration.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
yield self.config if block_given?
|
16
|
+
self.register
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.register
|
20
|
+
new_config = self.config.dup
|
21
|
+
|
22
|
+
::Sidekiq.configure_server do |config|
|
23
|
+
config.server_middleware do |chain|
|
24
|
+
chain.remove Sidekiq::Instrumental::Middleware::Server
|
25
|
+
chain.add Sidekiq::Instrumental::Middleware::Server, new_config
|
26
|
+
end
|
27
|
+
config.client_middleware do |chain|
|
28
|
+
chain.remove Sidekiq::Instrumental::Middleware::Client
|
29
|
+
chain.add Sidekiq::Instrumental::Middleware::Client, new_config
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
::Sidekiq.configure_client do |config|
|
34
|
+
config.client_middleware do |chain|
|
35
|
+
chain.remove Sidekiq::Instrumental::Middleware::Client
|
36
|
+
chain.add Sidekiq::Instrumental::Middleware::Client, new_config
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Sidekiq::Instrumental.register
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sidekiq/instrumental/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sidekiq-instrumental"
|
8
|
+
spec.version = Sidekiq::Instrumental::VERSION
|
9
|
+
spec.authors = ["Edward Rudd"]
|
10
|
+
spec.email = ["urkle@outoforder.cc"]
|
11
|
+
|
12
|
+
spec.summary = %q{Send Sidekiq status into Instrumental after every job}
|
13
|
+
spec.homepage = "https://github.com/NetsoftHoldings/sidekiq-instrumental/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
spec.test_files = Dir['spec/**/*']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'instrumental_agent', ">= 0.13"
|
22
|
+
spec.add_runtime_dependency 'sidekiq', '>= 3.5'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
25
|
+
spec.add_development_dependency "simplecov", "~> 0.11"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
28
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Sidekiq::Instrumental::Configuration do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'should set enabled to true' do
|
6
|
+
expect(subject.enabled).to eq(true)
|
7
|
+
end
|
8
|
+
|
9
|
+
described_class::ARRAY_OPTIONS.each do |o|
|
10
|
+
it "should set #{o} to a blank array" do
|
11
|
+
expect(subject.send(o)).to eq([])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
shared_examples_for 'whitelist checks' do |option, method, list, value|
|
17
|
+
context 'when it is empty' do
|
18
|
+
before do
|
19
|
+
expect(subject.send(option)).to be_empty
|
20
|
+
end
|
21
|
+
it 'should return true' do
|
22
|
+
expect(subject.send(method, value)).to eq(true)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
context 'when it is not empty' do
|
26
|
+
before do
|
27
|
+
subject.send("#{option}=", list)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should be true when the list contains the entry' do
|
31
|
+
expect(subject.send(method, value)).to eq(true)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should be false when the list does not contain the entry' do
|
35
|
+
expect(subject.send(method, 'other')).to eq(false)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
shared_examples_for 'blacklist checks' do |option, method, list, value|
|
41
|
+
context 'when it is empty' do
|
42
|
+
before do
|
43
|
+
expect(subject.send(option)).to be_empty
|
44
|
+
end
|
45
|
+
it 'should return false' do
|
46
|
+
expect(subject.send(method, value)).to eq(false)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
context 'when it is not empty' do
|
50
|
+
before do
|
51
|
+
subject.send("#{option}=", list)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should be false when the list contains the entry' do
|
55
|
+
expect(subject.send(method, value)).to eq(true)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should be true when the list does not contain the entry' do
|
59
|
+
expect(subject.send(method, 'other')).to eq(false)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#queue_in_whitelist' do
|
66
|
+
include_examples 'whitelist checks', :whitelist_queues, :queue_in_whitelist, ['default'], 'default'
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#queue_in_blacklist' do
|
70
|
+
include_examples 'blacklist checks', :blacklist_queues, :queue_in_blacklist, ['default'], 'default'
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#class_in_whitelist' do
|
74
|
+
include_examples 'whitelist checks', :whitelist_classes, :class_in_whitelist, ['Array'], []
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#class_in_blacklist' do
|
78
|
+
include_examples 'blacklist checks', :blacklist_classes, :class_in_blacklist, ['Array'], []
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#allowed_to_submit' do
|
82
|
+
it 'when no lists defined it should always be true' do
|
83
|
+
expect(subject.allowed_to_submit('default', [])).to eq(true)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Sidekiq::Instrumental do
|
4
|
+
it 'has a version number' do
|
5
|
+
expect(described_class::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '::config' do
|
9
|
+
describe '::config' do
|
10
|
+
it 'should return a Configuration object' do
|
11
|
+
expect(described_class.config).to be_an_instance_of(described_class::Configuration)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '::configure' do
|
17
|
+
before do
|
18
|
+
allow(described_class).to receive(:register)
|
19
|
+
end
|
20
|
+
it 'should yield to the passed block' do
|
21
|
+
expect { |b| described_class.configure(&b) }.to yield_control
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should yield the configuration object' do
|
25
|
+
expect { |b| described_class.configure(&b) }.to yield_with_args(described_class.config)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '::register' do
|
30
|
+
context 'when sidekiq run as a server' do
|
31
|
+
before do
|
32
|
+
allow(Sidekiq).to receive(:server?).and_return(true)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should register server middleware' do
|
36
|
+
server_chain = double('Sidekick::MiddlewareChain')
|
37
|
+
config = double('Chain')
|
38
|
+
allow(config).to receive(:server_middleware).and_yield(server_chain)
|
39
|
+
allow(config).to receive(:client_middleware)
|
40
|
+
allow(Sidekiq).to receive(:configure_server).and_yield(config)
|
41
|
+
|
42
|
+
expect(server_chain).to receive(:remove).with(described_class::Middleware::Server)
|
43
|
+
expect(server_chain).to receive(:add).with(described_class::Middleware::Server, an_instance_of(described_class::Configuration))
|
44
|
+
|
45
|
+
described_class.register
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should register client middleware' do
|
49
|
+
client_chain = double('Sidekick::MiddlewareChain')
|
50
|
+
config = double('Sidekiq')
|
51
|
+
allow(config).to receive(:server_middleware)
|
52
|
+
allow(config).to receive(:client_middleware).and_yield(client_chain)
|
53
|
+
allow(Sidekiq).to receive(:configure_server).and_yield(config)
|
54
|
+
|
55
|
+
expect(client_chain).to receive(:remove).with(described_class::Middleware::Client)
|
56
|
+
expect(client_chain).to receive(:add).with(described_class::Middleware::Client, an_instance_of(described_class::Configuration))
|
57
|
+
|
58
|
+
described_class.register
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when sidekiq not run as a server' do
|
63
|
+
it 'should register client middleware' do
|
64
|
+
client_chain = double('Sidekick::MiddlewareChain')
|
65
|
+
config = double('Sidekiq')
|
66
|
+
allow(config).to receive(:client_middleware).and_yield(client_chain)
|
67
|
+
allow(Sidekiq).to receive(:configure_client).and_yield(config)
|
68
|
+
|
69
|
+
expect(client_chain).to receive(:remove).with(described_class::Middleware::Client)
|
70
|
+
expect(client_chain).to receive(:add).with(described_class::Middleware::Client, an_instance_of(described_class::Configuration))
|
71
|
+
|
72
|
+
described_class.register
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'simplecov'
|
3
|
+
require 'sidekiq/instrumental'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.expect_with :rspec do |expectations|
|
7
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
8
|
+
end
|
9
|
+
|
10
|
+
config.mock_with :rspec do |mocks|
|
11
|
+
mocks.verify_partial_doubles = true
|
12
|
+
end
|
13
|
+
|
14
|
+
config.disable_monkey_patching!
|
15
|
+
|
16
|
+
config.order = :random
|
17
|
+
|
18
|
+
Kernel.srand config.seed
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sidekiq-instrumental
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Edward Rudd
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: instrumental_agent
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sidekiq
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.4'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- urkle@outoforder.cc
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".simplecov"
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- circle.yml
|
114
|
+
- lib/sidekiq/instrumental.rb
|
115
|
+
- lib/sidekiq/instrumental/configuration.rb
|
116
|
+
- lib/sidekiq/instrumental/middleware/base.rb
|
117
|
+
- lib/sidekiq/instrumental/middleware/client.rb
|
118
|
+
- lib/sidekiq/instrumental/middleware/server.rb
|
119
|
+
- lib/sidekiq/instrumental/version.rb
|
120
|
+
- sidekiq-instrumental.gemspec
|
121
|
+
- spec/sidekiq/instrumental/configuration_spec.rb
|
122
|
+
- spec/sidekiq/instrumental_spec.rb
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
homepage: https://github.com/NetsoftHoldings/sidekiq-instrumental/
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.4.3
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Send Sidekiq status into Instrumental after every job
|
148
|
+
test_files:
|
149
|
+
- spec/sidekiq/instrumental/configuration_spec.rb
|
150
|
+
- spec/sidekiq/instrumental_spec.rb
|
151
|
+
- spec/spec_helper.rb
|