inst-jobs-statsd 1.4.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inst-jobs-statsd.rb +1 -1
- data/lib/inst_jobs_statsd/ext/job.rb +11 -0
- data/lib/inst_jobs_statsd/jobs_tracker.rb +1 -1
- data/lib/inst_jobs_statsd/naming.rb +2 -2
- data/lib/inst_jobs_statsd/version.rb +1 -1
- data/spec/inst_jobs_statsd/ext/job_spec.rb +15 -0
- data/spec/inst_jobs_statsd/jobs_tracker_spec.rb +0 -1
- data/spec/inst_jobs_statsd/naming_spec.rb +2 -2
- data/spec/inst_jobs_statsd/stats/counters/run_spec.rb +2 -2
- data/spec/inst_jobs_statsd/stats/periodic/failed_spec.rb +2 -2
- data/spec/inst_jobs_statsd/stats/periodic/queue_spec.rb +17 -17
- data/spec/inst_jobs_statsd/stats/periodic/run_spec.rb +7 -7
- data/spec/setup_test_db.rb +0 -4
- data/spec/spec_helper.rb +1 -1
- metadata +16 -20
- data/lib/inst_jobs_statsd/stats/counters/failed.rb +0 -28
- data/spec/gemfiles/42.gemfile +0 -8
- data/spec/gemfiles/51.gemfile +0 -8
- data/spec/inst_jobs_statsd/stats/counters/failed_spec.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd7dc1bb11dbc52f03746c3003067ab3583c2941bbde910a5afebe56a3b67db8
|
4
|
+
data.tar.gz: 7fda921fe197a011e611d5b9a6840c670064970cf62e536caa1b8600c78e7e02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a3cf26ef4330f4cb30ffa49b00d4bb9926c4b8098c62946539fdac755afb7e58cf009c21231ff046eab196eb0cf5b9aaca2a3653ac0156705207f10ad35b715
|
7
|
+
data.tar.gz: 945d7bdb0a403f99a75baabaa70985d1094c6cbe069e244f872d835082dfcf178ca9280a8688c697ce9ee4f1af95a9341051a9437e6a1ade65d92b84ea9fff47
|
data/lib/inst-jobs-statsd.rb
CHANGED
@@ -9,7 +9,6 @@ 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'
|
13
12
|
require_relative 'inst_jobs_statsd/stats/counters/run'
|
14
13
|
|
15
14
|
require_relative 'inst_jobs_statsd/stats/periodic'
|
@@ -21,5 +20,6 @@ require_relative 'inst_jobs_statsd/stats/timing'
|
|
21
20
|
require_relative 'inst_jobs_statsd/stats/timing/failed'
|
22
21
|
require_relative 'inst_jobs_statsd/stats/timing/perform'
|
23
22
|
require_relative 'inst_jobs_statsd/stats/timing/pop'
|
23
|
+
require_relative 'inst_jobs_statsd/ext/job'
|
24
24
|
|
25
25
|
::InstStatsd::DefaultTracking.include InstJobsStatsd::DefaultTracking
|
@@ -9,8 +9,8 @@ module InstJobsStatsd
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize(enable_periodic_queries: true)
|
12
|
-
Stats::Counters::Failed.enable
|
13
12
|
Stats::Counters::Run.enable
|
13
|
+
::Delayed::Job.prepend InstJobsStatsd::Ext::Job
|
14
14
|
|
15
15
|
if enable_periodic_queries
|
16
16
|
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
|
-
|
94
|
+
[method_tag, obj_tag]
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -0,0 +1,15 @@
|
|
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
|
+
expect(InstStatsd::Statsd).to receive(:count)
|
9
|
+
.with(array_including(/\.failed$/), 1, 1, short_stat: :failed, tags: {})
|
10
|
+
|
11
|
+
x.delay.perform
|
12
|
+
Delayed::Job.first.fail!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -12,7 +12,6 @@ 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)
|
16
15
|
expect(InstJobsStatsd::Stats::Counters::Run).to receive(:enable)
|
17
16
|
|
18
17
|
expect(InstJobsStatsd::Stats::Periodic::Failed).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(
|
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(
|
52
|
+
expect(InstJobsStatsd::Naming.dd_job_tags(job)).to eq(tag: 'Quizzes-Quiz.do_something')
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -13,12 +13,12 @@ RSpec.describe InstJobsStatsd::Stats::Counters::Run do
|
|
13
13
|
Delayed::Worker.lifecycle.reset!
|
14
14
|
InstJobsStatsd::Stats::Counters::Run.enable
|
15
15
|
|
16
|
-
2.times { x.
|
16
|
+
2.times { x.delay.perform }
|
17
17
|
end
|
18
18
|
|
19
19
|
it do
|
20
20
|
expect(InstStatsd::Statsd).to receive(:count)
|
21
|
-
.twice.with(array_including(/\.run$/), 1, 1,
|
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
|
@@ -18,13 +18,13 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Failed do
|
|
18
18
|
InstJobsStatsd::Stats::Periodic.enable_callbacks
|
19
19
|
InstJobsStatsd::Stats::Periodic::Failed.enable_failed_depth
|
20
20
|
|
21
|
-
x.
|
21
|
+
x.delay.perform
|
22
22
|
Delayed::Job.first.fail!
|
23
23
|
end
|
24
24
|
|
25
25
|
it do
|
26
26
|
expect(InstStatsd::Statsd).to receive(:gauge)
|
27
|
-
.with(array_including(/\.failed_depth$/), 1, 1,
|
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
|
@@ -18,23 +18,23 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Queue do
|
|
18
18
|
before do
|
19
19
|
InstJobsStatsd::Stats::Periodic::Queue.enable_queue_depth
|
20
20
|
|
21
|
-
x.
|
21
|
+
x.delay.perform
|
22
22
|
Delayed::Job.first.update(locked_at: Delayed::Job.db_time_now, locked_by: 'test')
|
23
23
|
|
24
|
-
x.
|
25
|
-
x.
|
26
|
-
x.
|
24
|
+
x.delay.perform
|
25
|
+
x.delay(run_at: now + 1.minute).perform
|
26
|
+
x.delay(run_at: now + 10.minutes).perform
|
27
27
|
end
|
28
28
|
|
29
29
|
it do
|
30
30
|
expect(InstStatsd::Statsd).to receive(:gauge)
|
31
|
-
.with(array_including(/\.queue_depth$/), 1, 1,
|
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,
|
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,
|
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
|
@@ -56,27 +56,27 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Queue do
|
|
56
56
|
before do
|
57
57
|
InstJobsStatsd::Stats::Periodic::Queue.enable_queue_age
|
58
58
|
|
59
|
-
x.
|
59
|
+
x.delay.perform
|
60
60
|
Delayed::Job.first.update(locked_at: Delayed::Job.db_time_now, locked_by: 'test')
|
61
61
|
|
62
|
-
x.
|
63
|
-
x.
|
64
|
-
x.
|
62
|
+
x.delay.perform
|
63
|
+
x.delay(run_at: now + 1.minute).perform
|
64
|
+
x.delay(run_at: now + 10.minutes).perform
|
65
65
|
end
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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
|
@@ -18,14 +18,14 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Run do
|
|
18
18
|
before do
|
19
19
|
InstJobsStatsd::Stats::Periodic::Run.enable_run_depth
|
20
20
|
|
21
|
-
x.
|
22
|
-
x.
|
21
|
+
x.delay.perform
|
22
|
+
x.delay.perform
|
23
23
|
Delayed::Job.first.update(locked_at: Delayed::Job.db_time_now, locked_by: 'test')
|
24
24
|
end
|
25
25
|
|
26
26
|
it do
|
27
27
|
expect(InstStatsd::Statsd).to receive(:gauge)
|
28
|
-
.with(array_including(/\.run_depth$/), 1, 1,
|
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
|
@@ -37,16 +37,16 @@ RSpec.describe InstJobsStatsd::Stats::Periodic::Run do
|
|
37
37
|
before do
|
38
38
|
InstJobsStatsd::Stats::Periodic::Run.enable_run_age
|
39
39
|
|
40
|
-
x.
|
41
|
-
x.
|
40
|
+
x.delay.perform
|
41
|
+
x.delay.perform
|
42
42
|
Delayed::Job.first.update(locked_at: now, locked_by: 'test')
|
43
43
|
end
|
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,
|
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,
|
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
|
data/spec/setup_test_db.rb
CHANGED
@@ -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
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: 1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Slade
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-30 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: '0
|
19
|
+
version: '1.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '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: '0
|
29
|
+
version: '1.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '0
|
32
|
+
version: '4.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: inst_statsd
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -232,7 +232,7 @@ dependencies:
|
|
232
232
|
- - "~>"
|
233
233
|
- !ruby/object:Gem::Version
|
234
234
|
version: 1.4.0
|
235
|
-
description:
|
235
|
+
description:
|
236
236
|
email:
|
237
237
|
- jslade@instructure.com
|
238
238
|
executables: []
|
@@ -241,10 +241,10 @@ 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
248
|
- lib/inst_jobs_statsd/stats/counters/run.rb
|
249
249
|
- lib/inst_jobs_statsd/stats/periodic.rb
|
250
250
|
- lib/inst_jobs_statsd/stats/periodic/failed.rb
|
@@ -257,12 +257,10 @@ files:
|
|
257
257
|
- lib/inst_jobs_statsd/version.rb
|
258
258
|
- spec/factories/jobs.rb
|
259
259
|
- spec/factories/workers.rb
|
260
|
-
- spec/gemfiles/42.gemfile
|
261
|
-
- spec/gemfiles/51.gemfile
|
262
260
|
- spec/gemfiles/60.gemfile
|
261
|
+
- spec/inst_jobs_statsd/ext/job_spec.rb
|
263
262
|
- spec/inst_jobs_statsd/jobs_tracker_spec.rb
|
264
263
|
- spec/inst_jobs_statsd/naming_spec.rb
|
265
|
-
- spec/inst_jobs_statsd/stats/counters/failed_spec.rb
|
266
264
|
- spec/inst_jobs_statsd/stats/counters/run_spec.rb
|
267
265
|
- spec/inst_jobs_statsd/stats/periodic/failed_spec.rb
|
268
266
|
- spec/inst_jobs_statsd/stats/periodic/queue_spec.rb
|
@@ -280,7 +278,7 @@ homepage: https://github.com/instructure/inst-jobs-statsd
|
|
280
278
|
licenses:
|
281
279
|
- MIT
|
282
280
|
metadata: {}
|
283
|
-
post_install_message:
|
281
|
+
post_install_message:
|
284
282
|
rdoc_options: []
|
285
283
|
require_paths:
|
286
284
|
- lib
|
@@ -295,11 +293,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
295
293
|
- !ruby/object:Gem::Version
|
296
294
|
version: '0'
|
297
295
|
requirements: []
|
298
|
-
rubygems_version: 3.
|
299
|
-
signing_key:
|
296
|
+
rubygems_version: 3.2.24
|
297
|
+
signing_key:
|
300
298
|
specification_version: 4
|
301
299
|
summary: Stats reporting for inst-jobs
|
302
300
|
test_files:
|
301
|
+
- spec/inst_jobs_statsd/ext/job_spec.rb
|
303
302
|
- spec/inst_jobs_statsd/naming_spec.rb
|
304
303
|
- spec/inst_jobs_statsd/stats/periodic/failed_spec.rb
|
305
304
|
- spec/inst_jobs_statsd/stats/periodic/run_spec.rb
|
@@ -308,7 +307,6 @@ test_files:
|
|
308
307
|
- spec/inst_jobs_statsd/stats/timing/pop_spec.rb
|
309
308
|
- spec/inst_jobs_statsd/stats/timing/perform_spec.rb
|
310
309
|
- spec/inst_jobs_statsd/stats/periodic_spec.rb
|
311
|
-
- spec/inst_jobs_statsd/stats/counters/failed_spec.rb
|
312
310
|
- spec/inst_jobs_statsd/stats/counters/run_spec.rb
|
313
311
|
- spec/inst_jobs_statsd/stats/timing_spec.rb
|
314
312
|
- spec/inst_jobs_statsd/jobs_tracker_spec.rb
|
@@ -316,8 +314,6 @@ test_files:
|
|
316
314
|
- spec/setup_test_db.rb
|
317
315
|
- spec/matchers.rb
|
318
316
|
- spec/gemfiles/60.gemfile
|
319
|
-
- spec/gemfiles/42.gemfile
|
320
|
-
- spec/gemfiles/51.gemfile
|
321
317
|
- spec/factories/workers.rb
|
322
318
|
- spec/factories/jobs.rb
|
323
319
|
- spec/inst_statsd/default_tracking_spec.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
|
data/spec/gemfiles/42.gemfile
DELETED
data/spec/gemfiles/51.gemfile
DELETED
@@ -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.send_later(:perform)
|
17
|
-
Delayed::Job.first.fail!
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|