sidekiq_queue_metrics 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +42 -0
- data/lib/sidekiq_queue_metrics/configuration.rb +17 -0
- data/lib/sidekiq_queue_metrics/monitor/job_death_monitor.rb +16 -0
- data/lib/sidekiq_queue_metrics/monitor/job_success_monitor.rb +14 -0
- data/lib/sidekiq_queue_metrics/monitor/monitor.rb +28 -0
- data/lib/sidekiq_queue_metrics/queue_metrics.rb +48 -0
- data/lib/sidekiq_queue_metrics/storage.rb +21 -0
- data/lib/sidekiq_queue_metrics/version.rb +5 -0
- data/lib/sidekiq_queue_metrics.rb +6 -0
- data/sidekiq_queue_metrics.gemspec +24 -0
- data/spec/lib/sidekiq_queue_metrics/monitor/job_death_monitor_spec.rb +48 -0
- data/spec/lib/sidekiq_queue_metrics/monitor/job_success_monitor_spec.rb +48 -0
- data/spec/lib/sidekiq_queue_metrics/queue_stats_spec.rb +68 -0
- data/spec/spec_helper.rb +104 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 29dc92024211cdda90be061af5243c1ab910a65a089bac50ed1a73895a787379
|
4
|
+
data.tar.gz: 233a08ee50bde2b48ba8cbb2f41c08bb2fd1e82822d4f9e397edce96c7f85b93
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6c6f87f0ba70fb343997faa730cf65abbf8f3f7a7930753ecffc36a0be95784b513a28b62770afcac98db7abc1eac6aa1adad794d0bfd88af64258b6eeaa10c4
|
7
|
+
data.tar.gz: 248fa5e9aa524002507412f06beed0d71b735444489906a225d3ad49ce8ffc445f70b3a3b6d640a57474a61bb555f0acf29bf50810be660ee10237f5006adcf8
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.idea
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
concurrent-ruby (1.0.5)
|
5
|
+
connection_pool (2.2.2)
|
6
|
+
diff-lcs (1.3)
|
7
|
+
eldritch (1.1.3)
|
8
|
+
reentrant_mutex (~> 1.1.0)
|
9
|
+
rack (2.0.5)
|
10
|
+
rack-protection (2.0.3)
|
11
|
+
rack
|
12
|
+
redis (4.0.1)
|
13
|
+
reentrant_mutex (1.1.1)
|
14
|
+
rspec (3.7.0)
|
15
|
+
rspec-core (~> 3.7.0)
|
16
|
+
rspec-expectations (~> 3.7.0)
|
17
|
+
rspec-mocks (~> 3.7.0)
|
18
|
+
rspec-core (3.7.1)
|
19
|
+
rspec-support (~> 3.7.0)
|
20
|
+
rspec-expectations (3.7.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.7.0)
|
23
|
+
rspec-mocks (3.7.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.7.0)
|
26
|
+
rspec-support (3.7.1)
|
27
|
+
sidekiq (5.1.3)
|
28
|
+
concurrent-ruby (~> 1.0)
|
29
|
+
connection_pool (~> 2.2, >= 2.2.0)
|
30
|
+
rack-protection (>= 1.5.0)
|
31
|
+
redis (>= 3.3.5, < 5)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
eldritch
|
38
|
+
rspec
|
39
|
+
sidekiq
|
40
|
+
|
41
|
+
BUNDLED WITH
|
42
|
+
1.16.1
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Sidekiq::QueueMetrics
|
2
|
+
def self.init(config)
|
3
|
+
config.server_middleware do |chain|
|
4
|
+
chain.add Sidekiq::QueueMetrics::JobSuccessMonitor
|
5
|
+
end
|
6
|
+
|
7
|
+
config.death_handlers << Sidekiq::QueueMetrics::JobDeathMonitor.proc
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.storage_location=(key)
|
11
|
+
@storage_location = key
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.storage_location
|
15
|
+
@storage_location
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'monitor'
|
2
|
+
|
3
|
+
module Sidekiq::QueueMetrics
|
4
|
+
class JobDeathMonitor < Monitor
|
5
|
+
def self.proc
|
6
|
+
Proc.new do |job, exception|
|
7
|
+
queue = job['queue']
|
8
|
+
JobDeathMonitor.new.monitor(queue)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def status_counter
|
13
|
+
'failed'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'sidekiq'
|
2
|
+
require 'sidekiq_queue_metrics/storage'
|
3
|
+
|
4
|
+
module Sidekiq::QueueMetrics
|
5
|
+
class Monitor
|
6
|
+
def monitor(queue)
|
7
|
+
stats = existing_stats
|
8
|
+
stats[queue] ||= {}
|
9
|
+
|
10
|
+
if stats[queue][status_counter].nil?
|
11
|
+
stats[queue][status_counter] = 1
|
12
|
+
else
|
13
|
+
stats[queue][status_counter] += 1
|
14
|
+
end
|
15
|
+
|
16
|
+
Storage.set_stats(stats.to_json)
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
def status_counter
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def existing_stats
|
25
|
+
JSON.load(Storage.get_stats || '{}')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'sidekiq_queue_metrics/storage'
|
2
|
+
|
3
|
+
module Sidekiq::QueueMetrics
|
4
|
+
class << self
|
5
|
+
def fetch
|
6
|
+
queues = []
|
7
|
+
success_and_failed_stats = enqueued_jobs = retry_stats = {}
|
8
|
+
together do
|
9
|
+
async do
|
10
|
+
queues = Sidekiq::Queue.all.map(&:name).map(&:to_s)
|
11
|
+
queues.each {|queue| enqueued_jobs[queue] = fetch_enqueued_jobs(queue)}
|
12
|
+
end
|
13
|
+
|
14
|
+
async {success_and_failed_stats = fetch_success_and_failed_stats}
|
15
|
+
async {retry_stats = fetch_retry_stats}
|
16
|
+
end
|
17
|
+
|
18
|
+
queues.map do |queue|
|
19
|
+
stats = {'processed' => 0, 'failed' => 0}
|
20
|
+
if success_and_failed_stats.has_key?(queue)
|
21
|
+
stats['processed'] = val_or_default(success_and_failed_stats[queue]['processed'])
|
22
|
+
stats['failed'] = val_or_default(success_and_failed_stats[queue]['failed'])
|
23
|
+
end
|
24
|
+
|
25
|
+
stats['enqueued'] = val_or_default(enqueued_jobs[queue])
|
26
|
+
stats['in_retry'] = val_or_default(retry_stats[queue])
|
27
|
+
{queue => stats}
|
28
|
+
end.reduce({}, :merge)
|
29
|
+
end
|
30
|
+
|
31
|
+
def fetch_success_and_failed_stats
|
32
|
+
JSON.load(Storage.get_stats || '{}')
|
33
|
+
end
|
34
|
+
|
35
|
+
def fetch_enqueued_jobs(queue)
|
36
|
+
Sidekiq::Queue.new(queue).size
|
37
|
+
end
|
38
|
+
|
39
|
+
def fetch_retry_stats
|
40
|
+
Sidekiq::RetrySet.new.group_by(&:queue).map {|queue, jobs| [queue, jobs.count]}.to_h
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def val_or_default(val, default = 0)
|
45
|
+
val || default
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Sidekiq::QueueMetrics
|
2
|
+
class Storage
|
3
|
+
class << self
|
4
|
+
def set_stats(key = stats_key, value)
|
5
|
+
Sidekiq.redis_pool.with do |conn|
|
6
|
+
conn.set(key, value)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_stats(key = stats_key)
|
11
|
+
Sidekiq.redis_pool.with do |conn|
|
12
|
+
conn.get(key)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def stats_key
|
17
|
+
Sidekiq::QueueMetrics.storage_location || 'queue_stats'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require_relative './lib/sidekiq_queue_metrics/version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'sidekiq_queue_metrics'
|
8
|
+
s.version = Sidekiq::QueueMetrics::VERSION
|
9
|
+
s.summary = 'Records stats of each sidekiq queue and exposes APIs to retrieve them'
|
10
|
+
s.authors = ['Ajit Singh']
|
11
|
+
s.email = 'jeetsingh.ajit@gamil.com'
|
12
|
+
s.license = 'MIT'
|
13
|
+
s.homepage = 'https://github.com/ajitsing/sidkiq_queue_metrics'
|
14
|
+
|
15
|
+
s.files = `git ls-files -z`.split("\x0")
|
16
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency 'sidekiq', '>= 3.0'
|
21
|
+
s.add_dependency 'eldritch'
|
22
|
+
s.add_development_dependency "bundler", "~> 1.5"
|
23
|
+
s.add_development_dependency 'rspec'
|
24
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
describe Sidekiq::QueueMetrics::JobDeathMonitor do
|
2
|
+
describe '#call' do
|
3
|
+
let(:job) {{'queue' => 'mailer_queue'}}
|
4
|
+
let(:exception) {double('exception')}
|
5
|
+
let(:monitor) {Sidekiq::QueueMetrics::JobDeathMonitor.proc}
|
6
|
+
|
7
|
+
context 'when stats does not exist' do
|
8
|
+
it 'should create stats key and add stats of queue' do
|
9
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(nil)
|
10
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with({mailer_queue: {failed: 1}}.to_json)
|
11
|
+
|
12
|
+
monitor.call(job)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when stats exists' do
|
17
|
+
it 'should create a new queue when it does not exist' do
|
18
|
+
existing_stats = {mailer_queue: {failed: 1}}.to_json
|
19
|
+
expected_stats = {mailer_queue: {failed: 1}, job_queue: {failed: 1}}.to_json
|
20
|
+
|
21
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(existing_stats)
|
22
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with(expected_stats)
|
23
|
+
|
24
|
+
monitor.call({'queue' => 'job_queue'})
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should update existing queue' do
|
28
|
+
existing_stats = {mailer_queue: {failed: 1}}.to_json
|
29
|
+
expected_stats = {mailer_queue: {failed: 2}}.to_json
|
30
|
+
|
31
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(existing_stats)
|
32
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with(expected_stats)
|
33
|
+
|
34
|
+
monitor.call(job)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should create failed counter when other counters exists' do
|
38
|
+
existing_stats = {mailer_queue: {processed: 1}}.to_json
|
39
|
+
expected_stats = {mailer_queue: {processed: 1, failed: 1}}.to_json
|
40
|
+
|
41
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(existing_stats)
|
42
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with(expected_stats)
|
43
|
+
|
44
|
+
monitor.call(job)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
describe Sidekiq::QueueMetrics::JobSuccessMonitor do
|
2
|
+
describe '#call' do
|
3
|
+
let(:job) {double('job')}
|
4
|
+
let(:worker) {double('worker')}
|
5
|
+
let(:monitor) {Sidekiq::QueueMetrics::JobSuccessMonitor.new}
|
6
|
+
|
7
|
+
context 'when stats does not exist' do
|
8
|
+
it 'should create stats key and add stats of queue' do
|
9
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(nil)
|
10
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with({mailer_queue: {processed: 1}}.to_json)
|
11
|
+
|
12
|
+
monitor.call(worker, job, 'mailer_queue')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when stats exists' do
|
17
|
+
it 'should create a new queue when it does not exist' do
|
18
|
+
existing_stats = {mailer_queue: {processed: 1}}.to_json
|
19
|
+
expected_stats = {mailer_queue: {processed: 1}, job_queue: {processed: 1}}.to_json
|
20
|
+
|
21
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(existing_stats)
|
22
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with(expected_stats)
|
23
|
+
|
24
|
+
monitor.call(worker, job, 'job_queue')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should update existing queue' do
|
28
|
+
existing_stats = {mailer_queue: {processed: 1}}.to_json
|
29
|
+
expected_stats = {mailer_queue: {processed: 2}}.to_json
|
30
|
+
|
31
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(existing_stats)
|
32
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with(expected_stats)
|
33
|
+
|
34
|
+
monitor.call(worker, job, 'mailer_queue')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should create failed counter when other counters exists' do
|
38
|
+
existing_stats = {mailer_queue: {failed: 1}}.to_json
|
39
|
+
expected_stats = {mailer_queue: {failed: 1, processed: 1}}.to_json
|
40
|
+
|
41
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(existing_stats)
|
42
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:set_stats).with(expected_stats)
|
43
|
+
|
44
|
+
monitor.call(worker, job, 'mailer_queue')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
describe Sidekiq::QueueMetrics do
|
2
|
+
describe '#fetch' do
|
3
|
+
before(:each) do
|
4
|
+
queues = [OpenStruct.new(name: :mailer_queue), OpenStruct.new(name: :heavy_jobs_queue)]
|
5
|
+
expect(Sidekiq::Queue).to receive(:all).and_return(queues)
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should fetch current queue stats' do
|
9
|
+
stats = {mailer_queue: {processed: 2, failed: 1}, heavy_jobs_queue: {processed: 1, failed: 0}}
|
10
|
+
jobs_in_retry_queue = [OpenStruct.new(queue: 'mailer_queue'), OpenStruct.new(queue: 'heavy_jobs_queue')]
|
11
|
+
|
12
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(stats.to_json)
|
13
|
+
expect(Sidekiq::RetrySet).to receive(:new).and_return(jobs_in_retry_queue)
|
14
|
+
expect(Sidekiq::Queue).to receive(:new).with('mailer_queue').and_return(OpenStruct.new(size: 1))
|
15
|
+
expect(Sidekiq::Queue).to receive(:new).with('heavy_jobs_queue').and_return(OpenStruct.new(size: 1))
|
16
|
+
|
17
|
+
queue_stats = Sidekiq::QueueMetrics.fetch
|
18
|
+
|
19
|
+
expect(queue_stats['mailer_queue']['processed']).to eq(2)
|
20
|
+
expect(queue_stats['mailer_queue']['failed']).to eq(1)
|
21
|
+
expect(queue_stats['mailer_queue']['enqueued']).to eq(1)
|
22
|
+
expect(queue_stats['mailer_queue']['in_retry']).to eq(1)
|
23
|
+
|
24
|
+
expect(queue_stats['heavy_jobs_queue']['processed']).to eq(1)
|
25
|
+
expect(queue_stats['heavy_jobs_queue']['failed']).to eq(0)
|
26
|
+
expect(queue_stats['heavy_jobs_queue']['enqueued']).to eq(1)
|
27
|
+
expect(queue_stats['heavy_jobs_queue']['in_retry']).to eq(1)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should have default value as zero' do
|
31
|
+
stats = {mailer_queue: {processed: 2}, heavy_jobs_queue: {failed: 1}}
|
32
|
+
jobs_in_retry_queue = []
|
33
|
+
|
34
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(stats.to_json)
|
35
|
+
expect(Sidekiq::RetrySet).to receive(:new).and_return(jobs_in_retry_queue)
|
36
|
+
expect(Sidekiq::Queue).to receive(:new).with('mailer_queue').and_return(OpenStruct.new(size: 0))
|
37
|
+
expect(Sidekiq::Queue).to receive(:new).with('heavy_jobs_queue').and_return(OpenStruct.new(size: 0))
|
38
|
+
|
39
|
+
queue_stats = Sidekiq::QueueMetrics.fetch
|
40
|
+
|
41
|
+
expect(queue_stats['mailer_queue']['processed']).to eq(2)
|
42
|
+
expect(queue_stats['mailer_queue']['failed']).to be_zero
|
43
|
+
expect(queue_stats['mailer_queue']['enqueued']).to be_zero
|
44
|
+
expect(queue_stats['mailer_queue']['in_retry']).to be_zero
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should return Sidekiq::QueueMetrics for all sidekiq queues' do
|
48
|
+
jobs_in_retry_queue = []
|
49
|
+
|
50
|
+
expect(Sidekiq::QueueMetrics::Storage).to receive(:get_stats).and_return(nil)
|
51
|
+
expect(Sidekiq::RetrySet).to receive(:new).and_return(jobs_in_retry_queue)
|
52
|
+
expect(Sidekiq::Queue).to receive(:new).with('mailer_queue').and_return(OpenStruct.new(size: 0))
|
53
|
+
expect(Sidekiq::Queue).to receive(:new).with('heavy_jobs_queue').and_return(OpenStruct.new(size: 0))
|
54
|
+
|
55
|
+
queue_stats = Sidekiq::QueueMetrics.fetch
|
56
|
+
|
57
|
+
expect(queue_stats['mailer_queue']['processed']).to be_zero
|
58
|
+
expect(queue_stats['mailer_queue']['failed']).to be_zero
|
59
|
+
expect(queue_stats['mailer_queue']['enqueued']).to be_zero
|
60
|
+
expect(queue_stats['mailer_queue']['in_retry']).to be_zero
|
61
|
+
|
62
|
+
expect(queue_stats['heavy_jobs_queue']['processed']).to be_zero
|
63
|
+
expect(queue_stats['heavy_jobs_queue']['failed']).to be_zero
|
64
|
+
expect(queue_stats['heavy_jobs_queue']['enqueued']).to be_zero
|
65
|
+
expect(queue_stats['heavy_jobs_queue']['in_retry']).to be_zero
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
#
|
17
|
+
|
18
|
+
require './lib/sidekiq_queue_metrics'
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
# rspec-expectations config goes here. You can use an alternate
|
22
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
23
|
+
# assertions if you prefer.
|
24
|
+
config.expect_with :rspec do |expectations|
|
25
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
26
|
+
# and `failure_message` of custom matchers include text for helper methods
|
27
|
+
# defined using `chain`, e.g.:
|
28
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
29
|
+
# # => "be bigger than 2 and smaller than 4"
|
30
|
+
# ...rather than:
|
31
|
+
# # => "be bigger than 2"
|
32
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
33
|
+
end
|
34
|
+
|
35
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
36
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
37
|
+
config.mock_with :rspec do |mocks|
|
38
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
39
|
+
# a real object. This is generally recommended, and will default to
|
40
|
+
# `true` in RSpec 4.
|
41
|
+
mocks.verify_partial_doubles = true
|
42
|
+
end
|
43
|
+
|
44
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
45
|
+
# have no way to turn it off -- the option exists only for backwards
|
46
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
47
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
48
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
49
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
50
|
+
|
51
|
+
# The settings below are suggested to provide a good initial experience
|
52
|
+
# with RSpec, but feel free to customize to your heart's content.
|
53
|
+
=begin
|
54
|
+
# This allows you to limit a spec run to individual examples or groups
|
55
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
56
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
57
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
58
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
59
|
+
config.filter_run_when_matching :focus
|
60
|
+
|
61
|
+
# Allows RSpec to persist some state between runs in order to support
|
62
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
63
|
+
# you configure your source control system to ignore this file.
|
64
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
65
|
+
|
66
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
67
|
+
# recommended. For more details, see:
|
68
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
69
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
70
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
71
|
+
config.disable_monkey_patching!
|
72
|
+
|
73
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
74
|
+
# be too noisy due to issues in dependencies.
|
75
|
+
config.warnings = true
|
76
|
+
|
77
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
78
|
+
# file, and it's useful to allow more verbose output when running an
|
79
|
+
# individual spec file.
|
80
|
+
if config.files_to_run.one?
|
81
|
+
# Use the documentation formatter for detailed output,
|
82
|
+
# unless a formatter has already been configured
|
83
|
+
# (e.g. via a command-line flag).
|
84
|
+
config.default_formatter = "doc"
|
85
|
+
end
|
86
|
+
|
87
|
+
# Print the 10 slowest examples and example groups at the
|
88
|
+
# end of the spec run, to help surface which specs are running
|
89
|
+
# particularly slow.
|
90
|
+
config.profile_examples = 10
|
91
|
+
|
92
|
+
# Run specs in random order to surface order dependencies. If you find an
|
93
|
+
# order dependency and want to debug it, you can fix the order by providing
|
94
|
+
# the seed, which is printed after each run.
|
95
|
+
# --seed 1234
|
96
|
+
config.order = :random
|
97
|
+
|
98
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
99
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
100
|
+
# test failures related to randomization by passing the same `--seed` value
|
101
|
+
# as the one that triggered the failure.
|
102
|
+
Kernel.srand config.seed
|
103
|
+
=end
|
104
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sidekiq_queue_metrics
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ajit Singh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sidekiq
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: eldritch
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
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.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email: jeetsingh.ajit@gamil.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- ".gitignore"
|
76
|
+
- ".rspec"
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- lib/sidekiq_queue_metrics.rb
|
80
|
+
- lib/sidekiq_queue_metrics/configuration.rb
|
81
|
+
- lib/sidekiq_queue_metrics/monitor/job_death_monitor.rb
|
82
|
+
- lib/sidekiq_queue_metrics/monitor/job_success_monitor.rb
|
83
|
+
- lib/sidekiq_queue_metrics/monitor/monitor.rb
|
84
|
+
- lib/sidekiq_queue_metrics/queue_metrics.rb
|
85
|
+
- lib/sidekiq_queue_metrics/storage.rb
|
86
|
+
- lib/sidekiq_queue_metrics/version.rb
|
87
|
+
- sidekiq_queue_metrics.gemspec
|
88
|
+
- spec/lib/sidekiq_queue_metrics/monitor/job_death_monitor_spec.rb
|
89
|
+
- spec/lib/sidekiq_queue_metrics/monitor/job_success_monitor_spec.rb
|
90
|
+
- spec/lib/sidekiq_queue_metrics/queue_stats_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
homepage: https://github.com/ajitsing/sidkiq_queue_metrics
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.7.6
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Records stats of each sidekiq queue and exposes APIs to retrieve them
|
116
|
+
test_files:
|
117
|
+
- spec/lib/sidekiq_queue_metrics/monitor/job_death_monitor_spec.rb
|
118
|
+
- spec/lib/sidekiq_queue_metrics/monitor/job_success_monitor_spec.rb
|
119
|
+
- spec/lib/sidekiq_queue_metrics/queue_stats_spec.rb
|
120
|
+
- spec/spec_helper.rb
|