inst-jobs-statsd 2.1.0 → 2.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
  SHA256:
3
- metadata.gz: c7d2f71f91477c6e30a43226165ea6506e6e7b186f3fcf4876ce3b99d8595cd1
4
- data.tar.gz: a57c33ba7eb726155f0aa767a18dffc7cfb39f0faae21c51133d233076f7954d
3
+ metadata.gz: 10d4bb1c1c2d71c7a93df1ccd59657c96f871dd65b4e90ea7430fdf7b6da4991
4
+ data.tar.gz: f8af74f6d0e5abd4ec7f490ad592ee75c2909126574d889d275d7e8a2227df8d
5
5
  SHA512:
6
- metadata.gz: 7a692a9342cceb3ab900493cda108515956203e30d83acd048b96f3da2a9978f59ea711196aac5ed1c0156001847bd06548a36cd2b8e395be80a2309f077a620
7
- data.tar.gz: 70018e665a4e434fc6828391d0f67f753fb09569db8991baee0d44bfa72c73b9b3e770d5ecf8d6e0f1173961497ca586c96c552c10dfdef746c97157aea501e1
6
+ metadata.gz: 26f9240b397a8012fd8173c1a4658c53b7106eeecb4c2c833c82e2dc7963b4b73bb38bd442b469fcd551636f49c998daea5c8f7d7d929e5f7b3c0e1ac5361172
7
+ data.tar.gz: 8704615a3f54eed9d808930932ebb293818ab7af537bfc8e3a88cff6de685e3e6b3153342f643d1547f84f8a4c34b1181cc2d830cc3a91520b5e5e398d093d1c
@@ -9,8 +9,9 @@ require_relative 'inst_jobs_statsd/jobs_tracker'
9
9
  require_relative 'inst_jobs_statsd/naming'
10
10
 
11
11
  require_relative 'inst_jobs_statsd/stats/counters'
12
- require_relative 'inst_jobs_statsd/stats/counters/failed'
12
+ require_relative 'inst_jobs_statsd/stats/counters/create'
13
13
  require_relative 'inst_jobs_statsd/stats/counters/run'
14
+ require_relative 'inst_jobs_statsd/stats/counters/complete'
14
15
 
15
16
  require_relative 'inst_jobs_statsd/stats/periodic'
16
17
  require_relative 'inst_jobs_statsd/stats/periodic/failed'
@@ -21,5 +22,6 @@ require_relative 'inst_jobs_statsd/stats/timing'
21
22
  require_relative 'inst_jobs_statsd/stats/timing/failed'
22
23
  require_relative 'inst_jobs_statsd/stats/timing/perform'
23
24
  require_relative 'inst_jobs_statsd/stats/timing/pop'
25
+ require_relative 'inst_jobs_statsd/ext/job'
24
26
 
25
27
  ::InstStatsd::DefaultTracking.include InstJobsStatsd::DefaultTracking
@@ -0,0 +1,11 @@
1
+ module InstJobsStatsd
2
+ module Ext
3
+ module Job
4
+ def fail!
5
+ failed_job = super
6
+ InstJobsStatsd::Stats::Counters.report_count(:failed, 1, job: failed_job)
7
+ failed_job
8
+ end
9
+ end
10
+ end
11
+ end
@@ -9,8 +9,10 @@ module InstJobsStatsd
9
9
  end
10
10
 
11
11
  def initialize(enable_periodic_queries: true)
12
- Stats::Counters::Failed.enable
12
+ Stats::Counters::Create.enable
13
13
  Stats::Counters::Run.enable
14
+ Stats::Counters::Complete.enable
15
+ ::Delayed::Job.prepend InstJobsStatsd::Ext::Job
14
16
 
15
17
  if enable_periodic_queries
16
18
  Stats::Periodic::Failed.enable
@@ -82,7 +82,7 @@ module InstJobsStatsd
82
82
 
83
83
  def self.dd_region_tags
84
84
  return {} unless ENV['INST_JOBS_STATSD_NAMESPACE']
85
- {namespace: ENV['INST_JOBS_STATSD_NAMESPACE']}
85
+ { namespace: ENV['INST_JOBS_STATSD_NAMESPACE'] }
86
86
  end
87
87
 
88
88
  private
@@ -91,7 +91,7 @@ module InstJobsStatsd
91
91
  obj_tag, method_tag = job.tag.split(/[\.#]/, 2).map do |v|
92
92
  InstStatsd::Statsd.escape(v).gsub('::', '-')
93
93
  end
94
- return method_tag, obj_tag
94
+ [method_tag, obj_tag]
95
95
  end
96
96
  end
97
97
  end
@@ -0,0 +1,21 @@
1
+ module InstJobsStatsd
2
+ module Stats
3
+ module Counters
4
+ module Complete
5
+ def self.enable
6
+ enable_complete_count
7
+ end
8
+
9
+ def self.enable_complete_count
10
+ Delayed::Worker.lifecycle.after(:perform) do |_worker, job|
11
+ report_complete_count(job)
12
+ end
13
+ end
14
+
15
+ def self.report_complete_count(job)
16
+ Counters.report_count(:complete, 1, job: job)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module InstJobsStatsd
2
+ module Stats
3
+ module Counters
4
+ module Create
5
+ def self.enable
6
+ enable_create_count
7
+ end
8
+
9
+ def self.enable_create_count
10
+ Delayed::Worker.lifecycle.after(:create) do |_, result:|
11
+ report_create_count(result)
12
+ end
13
+ end
14
+
15
+ def self.report_create_count(job)
16
+ Counters.report_count(:create, 1, job: job)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module InstJobsStatsd
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = '2.2.0'.freeze
3
3
  end
@@ -0,0 +1,17 @@
1
+ RSpec.describe 'InstJobsStatsd::Ext::Job' do
2
+ describe 'sends count on job failure' do
3
+ before do
4
+ InstJobsStatsd::JobsTracker.new
5
+ end
6
+ let(:x) { Struct.new(:perform).new(true) }
7
+ it 'sends a stat' do
8
+ allow(InstStatsd::Statsd).to receive(:count)
9
+
10
+ x.delay.perform
11
+ Delayed::Job.first.fail!
12
+
13
+ expect(InstStatsd::Statsd).to have_received(:count)
14
+ .with(array_including(/\.failed$/), 1, 1, short_stat: :failed, tags: {})
15
+ end
16
+ end
17
+ end
@@ -12,8 +12,9 @@ RSpec.describe InstJobsStatsd::JobsTracker do
12
12
 
13
13
  describe '.initialize' do
14
14
  it 'enables everything' do
15
- expect(InstJobsStatsd::Stats::Counters::Failed).to receive(:enable)
15
+ expect(InstJobsStatsd::Stats::Counters::Create).to receive(:enable)
16
16
  expect(InstJobsStatsd::Stats::Counters::Run).to receive(:enable)
17
+ expect(InstJobsStatsd::Stats::Counters::Complete).to receive(:enable)
17
18
 
18
19
  expect(InstJobsStatsd::Stats::Periodic::Failed).to receive(:enable)
19
20
  expect(InstJobsStatsd::Stats::Periodic::Queue).to receive(:enable)
@@ -44,12 +44,12 @@ RSpec.describe InstJobsStatsd::Naming do
44
44
  describe '.dd_job_tags' do
45
45
  it 'works' do
46
46
  job = double(tag: 'Account.run_reports_later', shard: double(id: 101), strand: 'special')
47
- expect(InstJobsStatsd::Naming.dd_job_tags(job)).to eq({ tag: 'Account.run_reports_later', jobshard: 101})
47
+ expect(InstJobsStatsd::Naming.dd_job_tags(job)).to eq(tag: 'Account.run_reports_later', jobshard: 101)
48
48
  end
49
49
 
50
50
  it 'properly munges job tags' do
51
51
  job = double(tag: 'Quizzes::Quiz#do_something', strand: nil)
52
- expect(InstJobsStatsd::Naming.dd_job_tags(job)).to eq({ tag: 'Quizzes-Quiz.do_something'})
52
+ expect(InstJobsStatsd::Naming.dd_job_tags(job)).to eq(tag: 'Quizzes-Quiz.do_something')
53
53
  end
54
54
  end
55
55
  end
@@ -0,0 +1,27 @@
1
+ RSpec.describe InstJobsStatsd::Stats::Counters::Complete do
2
+ describe '.enable' do
3
+ it 'enables all the things' do
4
+ expect(InstJobsStatsd::Stats::Counters::Complete).to receive(:enable_complete_count)
5
+ InstJobsStatsd::Stats::Counters::Complete.enable
6
+ end
7
+ end
8
+
9
+ describe '.report_complete_count' do
10
+ let(:x) { Struct.new(:perform).new(true) }
11
+
12
+ before do
13
+ Delayed::Worker.lifecycle.reset!
14
+ InstJobsStatsd::Stats::Counters::Complete.enable
15
+
16
+ 2.times { x.delay.perform }
17
+ end
18
+
19
+ it "increments the counter" do
20
+ expect(InstStatsd::Statsd).to receive(:count)
21
+ .twice.with(array_including(/\.complete$/), 1, 1, short_stat: anything, tags: {})
22
+ Delayed::Job.all.each do |job|
23
+ Delayed::Worker.lifecycle.run_callbacks(:perform, {}, job) {}
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ RSpec.describe InstJobsStatsd::Stats::Counters::Create do
2
+ describe '.enable' do
3
+ it 'enables all the things' do
4
+ expect(InstJobsStatsd::Stats::Counters::Create).to receive(:enable_create_count)
5
+ InstJobsStatsd::Stats::Counters::Create.enable
6
+ end
7
+ end
8
+
9
+ describe '.report_create_count' do
10
+ let(:x) { Struct.new(:perform).new(true) }
11
+
12
+ before do
13
+ Delayed::Worker.lifecycle.reset!
14
+ InstJobsStatsd::Stats::Counters::Create.enable
15
+
16
+ 2.times { x.delay.perform }
17
+ end
18
+
19
+ it "increments the counter" do
20
+ expect(InstStatsd::Statsd).to receive(:count)
21
+ .twice.with(array_including(/\.create$/), 1, 1, short_stat: anything, tags: {})
22
+ Delayed::Job.all.each do |job|
23
+ Delayed::Worker.lifecycle.run_callbacks(:create, job) {}
24
+ end
25
+ end
26
+ end
27
+ end
@@ -18,7 +18,7 @@ RSpec.describe InstJobsStatsd::Stats::Counters::Run do
18
18
 
19
19
  it do
20
20
  expect(InstStatsd::Statsd).to receive(:count)
21
- .twice.with(array_including(/\.run$/), 1, 1, { short_stat: anything, tags: {} })
21
+ .twice.with(array_including(/\.run$/), 1, 1, short_stat: anything, tags: {})
22
22
  Delayed::Job.all.each do |job|
23
23
  Delayed::Worker.lifecycle.run_callbacks(:perform, {}, job) {}
24
24
  end
@@ -24,7 +24,7 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Failed do
24
24
 
25
25
  it do
26
26
  expect(InstStatsd::Statsd).to receive(:gauge)
27
- .with(array_including(/\.failed_depth$/), 1, 1, { short_stat: anything, tags: {} })
27
+ .with(array_including(/\.failed_depth$/), 1, 1, short_stat: anything, tags: {})
28
28
  InstJobsStatsd::Stats::Periodic::Failed.report_failed_depth
29
29
  end
30
30
  end
@@ -28,13 +28,13 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Queue do
28
28
 
29
29
  it do
30
30
  expect(InstStatsd::Statsd).to receive(:gauge)
31
- .with(array_including(/\.queue_depth$/), 1, 1, { short_stat: anything, tags: {} })
31
+ .with(array_including(/\.queue_depth$/), 1, 1, short_stat: anything, tags: {})
32
32
  InstJobsStatsd::Stats::Periodic::Queue.report_queue_depth
33
33
  end
34
34
 
35
35
  it do
36
36
  expect(InstStatsd::Statsd).to receive(:gauge)
37
- .with(array_including(/\.queue_depth$/), 2, 1, { short_stat: anything, tags: {} })
37
+ .with(array_including(/\.queue_depth$/), 2, 1, short_stat: anything, tags: {})
38
38
  Timecop.freeze(2.minutes.from_now) do
39
39
  InstJobsStatsd::Stats::Periodic::Queue.report_queue_depth
40
40
  end
@@ -42,7 +42,7 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Queue do
42
42
 
43
43
  it do
44
44
  expect(InstStatsd::Statsd).to receive(:gauge)
45
- .with(array_including(/\.queue_depth$/), 3, 1, { short_stat: anything, tags: {} })
45
+ .with(array_including(/\.queue_depth$/), 3, 1, short_stat: anything, tags: {})
46
46
  Timecop.freeze(20.minutes.from_now) do
47
47
  InstJobsStatsd::Stats::Periodic::Queue.report_queue_depth
48
48
  end
@@ -66,17 +66,17 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Queue do
66
66
 
67
67
  it do
68
68
  expect(InstStatsd::Statsd).to receive(:gauge)
69
- .ordered.with(array_including(/\.queue_age_total$/), number_near(0), 1, { short_stat: anything, tags: {} })
69
+ .ordered.with(array_including(/\.queue_age_total$/), number_near(0), 1, short_stat: anything, tags: {})
70
70
  expect(InstStatsd::Statsd).to receive(:gauge)
71
- .ordered.with(array_including(/\.queue_age_max$/), number_near(0), 1, { short_stat: anything, tags: {} })
71
+ .ordered.with(array_including(/\.queue_age_max$/), number_near(0), 1, short_stat: anything, tags: {})
72
72
  InstJobsStatsd::Stats::Periodic::Queue.report_queue_age
73
73
  end
74
74
 
75
75
  it do
76
76
  expect(InstStatsd::Statsd).to receive(:gauge)
77
- .ordered.with(array_including(/\.queue_age_total$/), number_near(180), 1, { short_stat: anything, tags: {} })
77
+ .ordered.with(array_including(/\.queue_age_total$/), number_near(180), 1, short_stat: anything, tags: {})
78
78
  expect(InstStatsd::Statsd).to receive(:gauge)
79
- .ordered.with(array_including(/\.queue_age_max$/), number_near(120), 1, { short_stat: anything, tags: {} })
79
+ .ordered.with(array_including(/\.queue_age_max$/), number_near(120), 1, short_stat: anything, tags: {})
80
80
  Timecop.freeze(2.minutes.from_now) do
81
81
  InstJobsStatsd::Stats::Periodic::Queue.report_queue_age
82
82
  end
@@ -84,9 +84,9 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Queue do
84
84
 
85
85
  it do
86
86
  expect(InstStatsd::Statsd).to receive(:gauge)
87
- .ordered.with(array_including(/\.queue_age_total$/), number_near(2940), 1, { short_stat: anything, tags: {} })
87
+ .ordered.with(array_including(/\.queue_age_total$/), number_near(2940), 1, short_stat: anything, tags: {})
88
88
  expect(InstStatsd::Statsd).to receive(:gauge)
89
- .ordered.with(array_including(/\.queue_age_max$/), number_near(1200), 1, { short_stat: anything, tags: {} })
89
+ .ordered.with(array_including(/\.queue_age_max$/), number_near(1200), 1, short_stat: anything, tags: {})
90
90
  Timecop.freeze(20.minutes.from_now) do
91
91
  InstJobsStatsd::Stats::Periodic::Queue.report_queue_age
92
92
  end
@@ -25,7 +25,7 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Run do
25
25
 
26
26
  it do
27
27
  expect(InstStatsd::Statsd).to receive(:gauge)
28
- .with(array_including(/\.run_depth$/), 1, 1, { short_stat: anything, tags: {} })
28
+ .with(array_including(/\.run_depth$/), 1, 1, short_stat: anything, tags: {})
29
29
  InstJobsStatsd::Stats::Periodic::Run.report_run_depth
30
30
  end
31
31
  end
@@ -44,9 +44,9 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Run do
44
44
 
45
45
  it do
46
46
  expect(InstStatsd::Statsd).to receive(:gauge)
47
- .ordered.with(array_including(/\.run_age_total$/), number_near(0), 1, { short_stat: anything, tags: {} })
47
+ .ordered.with(array_including(/\.run_age_total$/), number_near(0), 1, short_stat: anything, tags: {})
48
48
  expect(InstStatsd::Statsd).to receive(:gauge)
49
- .ordered.with(array_including(/\.run_age_max$/), number_near(0), 1, { short_stat: anything, tags: {} })
49
+ .ordered.with(array_including(/\.run_age_max$/), number_near(0), 1, short_stat: anything, tags: {})
50
50
  InstJobsStatsd::Stats::Periodic::Run.report_run_age
51
51
  end
52
52
  end
@@ -3,10 +3,6 @@
3
3
  ENV['TEST_ENV_NUMBER'] ||= '1'
4
4
  ENV['TEST_DB_HOST'] ||= 'localhost'
5
5
  ENV['TEST_DB_DATABASE'] ||= "inst-jobs-test-#{ENV['TEST_ENV_NUMBER']}"
6
- ENV['TEST_REDIS_CONNECTION'] ||= 'redis://localhost:6379/'
7
-
8
- Delayed::Backend::Redis::Job.redis = Redis.new(url: ENV['TEST_REDIS_CONNECTION'])
9
- Delayed::Backend::Redis::Job.redis.select ENV['TEST_ENV_NUMBER']
10
6
 
11
7
  connection_config = {
12
8
  adapter: :postgresql,
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- if /^2\.7/ =~ RUBY_VERSION && /51\./ =~ ENV['BUNDLE_GEMFILE'] # Limit coverage to one build
1
+ if /^2\.7/ =~ RUBY_VERSION && /60\./ =~ ENV['BUNDLE_GEMFILE'] # Limit coverage to one build
2
2
  require 'simplecov'
3
3
 
4
4
  SimpleCov.start do
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inst-jobs-statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Slade
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-08 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inst-jobs
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: 3.1.1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '3.0'
22
+ version: '4.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">"
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '1.0'
29
+ version: 3.1.1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '3.0'
32
+ version: '4.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: inst_statsd
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -241,10 +241,12 @@ extra_rdoc_files: []
241
241
  files:
242
242
  - lib/inst-jobs-statsd.rb
243
243
  - lib/inst_jobs_statsd/default_tracking.rb
244
+ - lib/inst_jobs_statsd/ext/job.rb
244
245
  - lib/inst_jobs_statsd/jobs_tracker.rb
245
246
  - lib/inst_jobs_statsd/naming.rb
246
247
  - lib/inst_jobs_statsd/stats/counters.rb
247
- - lib/inst_jobs_statsd/stats/counters/failed.rb
248
+ - lib/inst_jobs_statsd/stats/counters/complete.rb
249
+ - lib/inst_jobs_statsd/stats/counters/create.rb
248
250
  - lib/inst_jobs_statsd/stats/counters/run.rb
249
251
  - lib/inst_jobs_statsd/stats/periodic.rb
250
252
  - lib/inst_jobs_statsd/stats/periodic/failed.rb
@@ -257,12 +259,12 @@ files:
257
259
  - lib/inst_jobs_statsd/version.rb
258
260
  - spec/factories/jobs.rb
259
261
  - spec/factories/workers.rb
260
- - spec/gemfiles/42.gemfile
261
- - spec/gemfiles/51.gemfile
262
262
  - spec/gemfiles/60.gemfile
263
+ - spec/inst_jobs_statsd/ext/job_spec.rb
263
264
  - spec/inst_jobs_statsd/jobs_tracker_spec.rb
264
265
  - spec/inst_jobs_statsd/naming_spec.rb
265
- - spec/inst_jobs_statsd/stats/counters/failed_spec.rb
266
+ - spec/inst_jobs_statsd/stats/counters/complete_spec.rb
267
+ - spec/inst_jobs_statsd/stats/counters/create_spec.rb
266
268
  - spec/inst_jobs_statsd/stats/counters/run_spec.rb
267
269
  - spec/inst_jobs_statsd/stats/periodic/failed_spec.rb
268
270
  - spec/inst_jobs_statsd/stats/periodic/queue_spec.rb
@@ -295,29 +297,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
295
297
  - !ruby/object:Gem::Version
296
298
  version: '0'
297
299
  requirements: []
298
- rubygems_version: 3.0.3
300
+ rubygems_version: 3.1.4
299
301
  signing_key:
300
302
  specification_version: 4
301
303
  summary: Stats reporting for inst-jobs
302
304
  test_files:
305
+ - spec/factories/jobs.rb
306
+ - spec/factories/workers.rb
307
+ - spec/gemfiles/60.gemfile
308
+ - spec/inst_jobs_statsd/ext/job_spec.rb
309
+ - spec/inst_jobs_statsd/jobs_tracker_spec.rb
303
310
  - spec/inst_jobs_statsd/naming_spec.rb
311
+ - spec/inst_jobs_statsd/stats/counters/complete_spec.rb
312
+ - spec/inst_jobs_statsd/stats/counters/create_spec.rb
313
+ - spec/inst_jobs_statsd/stats/counters/run_spec.rb
304
314
  - spec/inst_jobs_statsd/stats/periodic/failed_spec.rb
305
- - spec/inst_jobs_statsd/stats/periodic/run_spec.rb
306
315
  - spec/inst_jobs_statsd/stats/periodic/queue_spec.rb
316
+ - spec/inst_jobs_statsd/stats/periodic/run_spec.rb
317
+ - spec/inst_jobs_statsd/stats/periodic_spec.rb
307
318
  - spec/inst_jobs_statsd/stats/timing/failed_spec.rb
308
- - spec/inst_jobs_statsd/stats/timing/pop_spec.rb
309
319
  - spec/inst_jobs_statsd/stats/timing/perform_spec.rb
310
- - spec/inst_jobs_statsd/stats/periodic_spec.rb
311
- - spec/inst_jobs_statsd/stats/counters/failed_spec.rb
312
- - spec/inst_jobs_statsd/stats/counters/run_spec.rb
320
+ - spec/inst_jobs_statsd/stats/timing/pop_spec.rb
313
321
  - spec/inst_jobs_statsd/stats/timing_spec.rb
314
- - spec/inst_jobs_statsd/jobs_tracker_spec.rb
315
- - spec/spec_helper.rb
316
- - spec/setup_test_db.rb
317
- - spec/matchers.rb
318
- - spec/gemfiles/60.gemfile
319
- - spec/gemfiles/42.gemfile
320
- - spec/gemfiles/51.gemfile
321
- - spec/factories/workers.rb
322
- - spec/factories/jobs.rb
323
322
  - spec/inst_statsd/default_tracking_spec.rb
323
+ - spec/matchers.rb
324
+ - spec/setup_test_db.rb
325
+ - spec/spec_helper.rb
@@ -1,28 +0,0 @@
1
- module InstJobsStatsd
2
- module Stats
3
- module Counters
4
- module Failed
5
- def self.enable
6
- enable_failed_count
7
- end
8
-
9
- def self.enable_failed_count
10
- return if Delayed::Job::Failed < AfterCreateHook
11
- Delayed::Job::Failed.include AfterCreateHook
12
- end
13
-
14
- module AfterCreateHook
15
- def self.included(base)
16
- base.after_create do
17
- InstJobsStatsd::Stats::Counters::Failed.report_failed_count(self)
18
- end
19
- end
20
- end
21
-
22
- def self.report_failed_count(job)
23
- Counters.report_count(:failed, 1, job: job)
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,8 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path=>"../../"
4
-
5
- gem "rails", "~> 4.2.11"
6
- gem "pg", "~> 0.21.0"
7
- gem "after_transaction_commit", "< 2"
8
- gem "test_after_commit", "1.1.0"
@@ -1,8 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path=>"../../"
4
-
5
- gem "rails", "~> 5.1.7"
6
- gem "sinatra", "~> 2.0.8"
7
- gem "sinatra-contrib", "~> 2.0.8"
8
- gem "sprockets", "~> 3.7" # 4.0+ requires Ruby 2.5
@@ -1,20 +0,0 @@
1
- RSpec.describe InstJobsStatsd::Stats::Counters::Failed do
2
- describe '.enable' do
3
- it 'enables all the things' do
4
- expect(InstJobsStatsd::Stats::Counters::Failed).to receive(:enable_failed_count)
5
- InstJobsStatsd::Stats::Counters::Failed.enable
6
- end
7
- end
8
-
9
- describe '.report_failed_count' do
10
- let(:x) { Struct.new(:perform).new(true) }
11
- it do
12
- expect(InstStatsd::Statsd).to receive(:count)
13
- .with(array_including(/\.failed$/), 1, 1, { short_stat: :failed, tags: {} })
14
-
15
- InstJobsStatsd::Stats::Counters::Failed.enable_failed_count
16
- x.delay.perform
17
- Delayed::Job.first.fail!
18
- end
19
- end
20
- end