inst-jobs-statsd 2.1.0 → 3.0.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 +22 -18
- data/lib/inst_jobs_statsd/default_tracking.rb +3 -1
- data/lib/inst_jobs_statsd/ext/job.rb +13 -0
- data/lib/inst_jobs_statsd/jobs_tracker.rb +5 -1
- data/lib/inst_jobs_statsd/naming.rb +20 -25
- data/lib/inst_jobs_statsd/stats/counters/complete.rb +23 -0
- data/lib/inst_jobs_statsd/stats/counters/create.rb +23 -0
- data/lib/inst_jobs_statsd/stats/counters/run.rb +2 -0
- data/lib/inst_jobs_statsd/stats/counters.rb +2 -0
- data/lib/inst_jobs_statsd/stats/periodic/failed.rb +2 -0
- data/lib/inst_jobs_statsd/stats/periodic/queue.rb +3 -1
- data/lib/inst_jobs_statsd/stats/periodic/run.rb +3 -1
- data/lib/inst_jobs_statsd/stats/periodic.rb +6 -2
- data/lib/inst_jobs_statsd/stats/timing/failed.rb +2 -0
- data/lib/inst_jobs_statsd/stats/timing/perform.rb +2 -0
- data/lib/inst_jobs_statsd/stats/timing/pop.rb +2 -0
- data/lib/inst_jobs_statsd/stats/timing.rb +7 -3
- data/lib/inst_jobs_statsd/version.rb +3 -1
- metadata +89 -92
- data/lib/inst_jobs_statsd/stats/counters/failed.rb +0 -28
- data/spec/factories/jobs.rb +0 -9
- data/spec/factories/workers.rb +0 -9
- data/spec/gemfiles/42.gemfile +0 -8
- data/spec/gemfiles/51.gemfile +0 -8
- data/spec/gemfiles/60.gemfile +0 -7
- data/spec/inst_jobs_statsd/jobs_tracker_spec.rb +0 -29
- data/spec/inst_jobs_statsd/naming_spec.rb +0 -56
- data/spec/inst_jobs_statsd/stats/counters/failed_spec.rb +0 -20
- data/spec/inst_jobs_statsd/stats/counters/run_spec.rb +0 -27
- data/spec/inst_jobs_statsd/stats/periodic/failed_spec.rb +0 -31
- data/spec/inst_jobs_statsd/stats/periodic/queue_spec.rb +0 -95
- data/spec/inst_jobs_statsd/stats/periodic/run_spec.rb +0 -53
- data/spec/inst_jobs_statsd/stats/periodic_spec.rb +0 -63
- data/spec/inst_jobs_statsd/stats/timing/failed_spec.rb +0 -25
- data/spec/inst_jobs_statsd/stats/timing/perform_spec.rb +0 -35
- data/spec/inst_jobs_statsd/stats/timing/pop_spec.rb +0 -34
- data/spec/inst_jobs_statsd/stats/timing_spec.rb +0 -35
- data/spec/inst_statsd/default_tracking_spec.rb +0 -16
- data/spec/matchers.rb +0 -3
- data/spec/setup_test_db.rb +0 -49
- data/spec/spec_helper.rb +0 -61
metadata
CHANGED
@@ -1,57 +1,51 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inst-jobs-statsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.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: 2023-10-02 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:
|
19
|
+
version: 3.1.1
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
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:
|
29
|
+
version: 3.1.1
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '4.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: inst_statsd
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 2.1.2
|
40
|
-
- - "<"
|
37
|
+
- - "~>"
|
41
38
|
- !ruby/object:Gem::Version
|
42
39
|
version: '3.0'
|
43
40
|
type: :runtime
|
44
41
|
prerelease: false
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
46
43
|
requirements:
|
47
|
-
- - "
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: 2.1.2
|
50
|
-
- - "<"
|
44
|
+
- - "~>"
|
51
45
|
- !ruby/object:Gem::Version
|
52
46
|
version: '3.0'
|
53
47
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
48
|
+
name: bundler
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|
56
50
|
requirements:
|
57
51
|
- - ">="
|
@@ -65,21 +59,21 @@ dependencies:
|
|
65
59
|
- !ruby/object:Gem::Version
|
66
60
|
version: '0'
|
67
61
|
- !ruby/object:Gem::Dependency
|
68
|
-
name:
|
62
|
+
name: database_cleaner
|
69
63
|
requirement: !ruby/object:Gem::Requirement
|
70
64
|
requirements:
|
71
|
-
- - "
|
65
|
+
- - "~>"
|
72
66
|
- !ruby/object:Gem::Version
|
73
|
-
version: '0'
|
67
|
+
version: '2.0'
|
74
68
|
type: :development
|
75
69
|
prerelease: false
|
76
70
|
version_requirements: !ruby/object:Gem::Requirement
|
77
71
|
requirements:
|
78
|
-
- - "
|
72
|
+
- - "~>"
|
79
73
|
- !ruby/object:Gem::Version
|
80
|
-
version: '0'
|
74
|
+
version: '2.0'
|
81
75
|
- !ruby/object:Gem::Dependency
|
82
|
-
name:
|
76
|
+
name: debug
|
83
77
|
requirement: !ruby/object:Gem::Requirement
|
84
78
|
requirements:
|
85
79
|
- - ">="
|
@@ -93,21 +87,7 @@ dependencies:
|
|
93
87
|
- !ruby/object:Gem::Version
|
94
88
|
version: '0'
|
95
89
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
98
|
-
requirements:
|
99
|
-
- - "~>"
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '1.7'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - "~>"
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '1.7'
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: factory_girl
|
90
|
+
name: factory_bot
|
111
91
|
requirement: !ruby/object:Gem::Requirement
|
112
92
|
requirements:
|
113
93
|
- - ">="
|
@@ -177,19 +157,75 @@ dependencies:
|
|
177
157
|
- !ruby/object:Gem::Version
|
178
158
|
version: '3.9'
|
179
159
|
- !ruby/object:Gem::Dependency
|
180
|
-
name: rubocop
|
160
|
+
name: rubocop-factory_bot
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '2.24'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '2.24'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: rubocop-inst
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - "~>"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '1.0'
|
180
|
+
type: :development
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - "~>"
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '1.0'
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
name: rubocop-rails
|
189
|
+
requirement: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - "~>"
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '2.21'
|
194
|
+
type: :development
|
195
|
+
prerelease: false
|
196
|
+
version_requirements: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - "~>"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '2.21'
|
201
|
+
- !ruby/object:Gem::Dependency
|
202
|
+
name: rubocop-rake
|
203
|
+
requirement: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - "~>"
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0.6'
|
208
|
+
type: :development
|
209
|
+
prerelease: false
|
210
|
+
version_requirements: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - "~>"
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0.6'
|
215
|
+
- !ruby/object:Gem::Dependency
|
216
|
+
name: rubocop-rspec
|
181
217
|
requirement: !ruby/object:Gem::Requirement
|
182
218
|
requirements:
|
183
219
|
- - "~>"
|
184
220
|
- !ruby/object:Gem::Version
|
185
|
-
version:
|
221
|
+
version: '2.24'
|
186
222
|
type: :development
|
187
223
|
prerelease: false
|
188
224
|
version_requirements: !ruby/object:Gem::Requirement
|
189
225
|
requirements:
|
190
226
|
- - "~>"
|
191
227
|
- !ruby/object:Gem::Version
|
192
|
-
version:
|
228
|
+
version: '2.24'
|
193
229
|
- !ruby/object:Gem::Dependency
|
194
230
|
name: simplecov
|
195
231
|
requirement: !ruby/object:Gem::Requirement
|
@@ -232,7 +268,7 @@ dependencies:
|
|
232
268
|
- - "~>"
|
233
269
|
- !ruby/object:Gem::Version
|
234
270
|
version: 1.4.0
|
235
|
-
description:
|
271
|
+
description:
|
236
272
|
email:
|
237
273
|
- jslade@instructure.com
|
238
274
|
executables: []
|
@@ -241,10 +277,12 @@ extra_rdoc_files: []
|
|
241
277
|
files:
|
242
278
|
- lib/inst-jobs-statsd.rb
|
243
279
|
- lib/inst_jobs_statsd/default_tracking.rb
|
280
|
+
- lib/inst_jobs_statsd/ext/job.rb
|
244
281
|
- lib/inst_jobs_statsd/jobs_tracker.rb
|
245
282
|
- lib/inst_jobs_statsd/naming.rb
|
246
283
|
- lib/inst_jobs_statsd/stats/counters.rb
|
247
|
-
- lib/inst_jobs_statsd/stats/counters/
|
284
|
+
- lib/inst_jobs_statsd/stats/counters/complete.rb
|
285
|
+
- lib/inst_jobs_statsd/stats/counters/create.rb
|
248
286
|
- lib/inst_jobs_statsd/stats/counters/run.rb
|
249
287
|
- lib/inst_jobs_statsd/stats/periodic.rb
|
250
288
|
- lib/inst_jobs_statsd/stats/periodic/failed.rb
|
@@ -255,32 +293,12 @@ files:
|
|
255
293
|
- lib/inst_jobs_statsd/stats/timing/perform.rb
|
256
294
|
- lib/inst_jobs_statsd/stats/timing/pop.rb
|
257
295
|
- lib/inst_jobs_statsd/version.rb
|
258
|
-
- spec/factories/jobs.rb
|
259
|
-
- spec/factories/workers.rb
|
260
|
-
- spec/gemfiles/42.gemfile
|
261
|
-
- spec/gemfiles/51.gemfile
|
262
|
-
- spec/gemfiles/60.gemfile
|
263
|
-
- spec/inst_jobs_statsd/jobs_tracker_spec.rb
|
264
|
-
- spec/inst_jobs_statsd/naming_spec.rb
|
265
|
-
- spec/inst_jobs_statsd/stats/counters/failed_spec.rb
|
266
|
-
- spec/inst_jobs_statsd/stats/counters/run_spec.rb
|
267
|
-
- spec/inst_jobs_statsd/stats/periodic/failed_spec.rb
|
268
|
-
- spec/inst_jobs_statsd/stats/periodic/queue_spec.rb
|
269
|
-
- spec/inst_jobs_statsd/stats/periodic/run_spec.rb
|
270
|
-
- spec/inst_jobs_statsd/stats/periodic_spec.rb
|
271
|
-
- spec/inst_jobs_statsd/stats/timing/failed_spec.rb
|
272
|
-
- spec/inst_jobs_statsd/stats/timing/perform_spec.rb
|
273
|
-
- spec/inst_jobs_statsd/stats/timing/pop_spec.rb
|
274
|
-
- spec/inst_jobs_statsd/stats/timing_spec.rb
|
275
|
-
- spec/inst_statsd/default_tracking_spec.rb
|
276
|
-
- spec/matchers.rb
|
277
|
-
- spec/setup_test_db.rb
|
278
|
-
- spec/spec_helper.rb
|
279
296
|
homepage: https://github.com/instructure/inst-jobs-statsd
|
280
297
|
licenses:
|
281
298
|
- MIT
|
282
|
-
metadata:
|
283
|
-
|
299
|
+
metadata:
|
300
|
+
rubygems_mfa_required: 'true'
|
301
|
+
post_install_message:
|
284
302
|
rdoc_options: []
|
285
303
|
require_paths:
|
286
304
|
- lib
|
@@ -288,36 +306,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
288
306
|
requirements:
|
289
307
|
- - ">="
|
290
308
|
- !ruby/object:Gem::Version
|
291
|
-
version: '2.
|
309
|
+
version: '2.7'
|
292
310
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
293
311
|
requirements:
|
294
312
|
- - ">="
|
295
313
|
- !ruby/object:Gem::Version
|
296
314
|
version: '0'
|
297
315
|
requirements: []
|
298
|
-
rubygems_version: 3.
|
299
|
-
signing_key:
|
316
|
+
rubygems_version: 3.4.19
|
317
|
+
signing_key:
|
300
318
|
specification_version: 4
|
301
319
|
summary: Stats reporting for inst-jobs
|
302
|
-
test_files:
|
303
|
-
- spec/inst_jobs_statsd/naming_spec.rb
|
304
|
-
- spec/inst_jobs_statsd/stats/periodic/failed_spec.rb
|
305
|
-
- spec/inst_jobs_statsd/stats/periodic/run_spec.rb
|
306
|
-
- spec/inst_jobs_statsd/stats/periodic/queue_spec.rb
|
307
|
-
- spec/inst_jobs_statsd/stats/timing/failed_spec.rb
|
308
|
-
- spec/inst_jobs_statsd/stats/timing/pop_spec.rb
|
309
|
-
- 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
|
313
|
-
- 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
|
-
- spec/inst_statsd/default_tracking_spec.rb
|
320
|
+
test_files: []
|
@@ -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/factories/jobs.rb
DELETED
data/spec/factories/workers.rb
DELETED
data/spec/gemfiles/42.gemfile
DELETED
data/spec/gemfiles/51.gemfile
DELETED
data/spec/gemfiles/60.gemfile
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
RSpec.describe InstJobsStatsd::JobsTracker do
|
2
|
-
describe '.track' do
|
3
|
-
it 'calls the block' do
|
4
|
-
@done_in_block = false
|
5
|
-
expect do
|
6
|
-
InstJobsStatsd::JobsTracker.track do
|
7
|
-
@done_in_block = true
|
8
|
-
end
|
9
|
-
end.to(change { @done_in_block })
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '.initialize' do
|
14
|
-
it 'enables everything' do
|
15
|
-
expect(InstJobsStatsd::Stats::Counters::Failed).to receive(:enable)
|
16
|
-
expect(InstJobsStatsd::Stats::Counters::Run).to receive(:enable)
|
17
|
-
|
18
|
-
expect(InstJobsStatsd::Stats::Periodic::Failed).to receive(:enable)
|
19
|
-
expect(InstJobsStatsd::Stats::Periodic::Queue).to receive(:enable)
|
20
|
-
expect(InstJobsStatsd::Stats::Periodic::Run).to receive(:enable)
|
21
|
-
|
22
|
-
expect(InstJobsStatsd::Stats::Timing::Failed).to receive(:enable)
|
23
|
-
expect(InstJobsStatsd::Stats::Timing::Perform).to receive(:enable)
|
24
|
-
expect(InstJobsStatsd::Stats::Timing::Pop).to receive(:enable)
|
25
|
-
|
26
|
-
InstJobsStatsd::JobsTracker.new
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
RSpec.describe InstJobsStatsd::Naming do
|
2
|
-
describe '.qualified_names' do
|
3
|
-
subject { InstJobsStatsd::Naming.qualified_names(stat_name, job) }
|
4
|
-
let(:stat_name) { :wut }
|
5
|
-
|
6
|
-
context 'when no job is given' do
|
7
|
-
let(:job) { nil }
|
8
|
-
it { should eq ['delayedjob.wut'] }
|
9
|
-
end
|
10
|
-
|
11
|
-
context 'when job is given' do
|
12
|
-
let(:job) { build :job }
|
13
|
-
it { should include 'delayedjob.wut.tag.Test-Job.perform' }
|
14
|
-
|
15
|
-
context 'job tag is unusual' do
|
16
|
-
let(:job) { build :job, tag: 'periodic__Something_on_a_schedule' }
|
17
|
-
it { should include 'delayedjob.wut.tag.periodic__Something_on_a_schedule' }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'job tag is dynamic' do
|
21
|
-
let(:job) { build :job, tag: '<Class:0x00000004f575b8>#perform' }
|
22
|
-
it { should eq ['delayedjob.wut'] }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'with region tags' do
|
27
|
-
before do
|
28
|
-
@jobs_namespace = ENV['INST_JOBS_STATSD_NAMESPACE']
|
29
|
-
ENV['INST_JOBS_STATSD_NAMESPACE'] = 'region_name'
|
30
|
-
end
|
31
|
-
|
32
|
-
after do
|
33
|
-
ENV['INST_JOBS_STATSD_NAMESPACE'] = @jobs_namespace
|
34
|
-
end
|
35
|
-
|
36
|
-
let(:job) { build :job, tag: 'a_tag_name' }
|
37
|
-
|
38
|
-
it { should include 'delayedjob.wut' }
|
39
|
-
it { should include 'delayedjob.wut.tag.a_tag_name' }
|
40
|
-
it { should include 'delayedjob.wut.region_name' }
|
41
|
-
it { should include 'delayedjob.wut.region_name.tag.a_tag_name' }
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '.dd_job_tags' do
|
45
|
-
it 'works' do
|
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})
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'properly munges job tags' do
|
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'})
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -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
|
@@ -1,27 +0,0 @@
|
|
1
|
-
RSpec.describe InstJobsStatsd::Stats::Counters::Run do
|
2
|
-
describe '.enable' do
|
3
|
-
it 'enables all the things' do
|
4
|
-
expect(InstJobsStatsd::Stats::Counters::Run).to receive(:enable_run_count)
|
5
|
-
InstJobsStatsd::Stats::Counters::Run.enable
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '.report_run_count' do
|
10
|
-
let(:x) { Struct.new(:perform).new(true) }
|
11
|
-
|
12
|
-
before do
|
13
|
-
Delayed::Worker.lifecycle.reset!
|
14
|
-
InstJobsStatsd::Stats::Counters::Run.enable
|
15
|
-
|
16
|
-
2.times { x.delay.perform }
|
17
|
-
end
|
18
|
-
|
19
|
-
it do
|
20
|
-
expect(InstStatsd::Statsd).to receive(:count)
|
21
|
-
.twice.with(array_including(/\.run$/), 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
|
@@ -1,31 +0,0 @@
|
|
1
|
-
RSpec.describe InstJobsStatsd::Stats::Periodic::Failed do
|
2
|
-
before do
|
3
|
-
InstJobsStatsd::Stats::Periodic.instance_variable_set(:@instance, nil)
|
4
|
-
end
|
5
|
-
|
6
|
-
describe '.enable' do
|
7
|
-
it 'enables all the things' do
|
8
|
-
expect(InstJobsStatsd::Stats::Periodic::Failed).to receive(:enable_failed_depth)
|
9
|
-
InstJobsStatsd::Stats::Periodic::Failed.enable
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '.report_failed_depth' do
|
14
|
-
let(:x) { Struct.new(:perform).new(true) }
|
15
|
-
let(:now) { Delayed::Job.db_time_now }
|
16
|
-
|
17
|
-
before do
|
18
|
-
InstJobsStatsd::Stats::Periodic.enable_callbacks
|
19
|
-
InstJobsStatsd::Stats::Periodic::Failed.enable_failed_depth
|
20
|
-
|
21
|
-
x.delay.perform
|
22
|
-
Delayed::Job.first.fail!
|
23
|
-
end
|
24
|
-
|
25
|
-
it do
|
26
|
-
expect(InstStatsd::Statsd).to receive(:gauge)
|
27
|
-
.with(array_including(/\.failed_depth$/), 1, 1, { short_stat: anything, tags: {} })
|
28
|
-
InstJobsStatsd::Stats::Periodic::Failed.report_failed_depth
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
RSpec.describe InstJobsStatsd::Stats::Periodic::Queue do
|
2
|
-
before do
|
3
|
-
InstJobsStatsd::Stats::Periodic.instance_variable_set(:@instance, nil)
|
4
|
-
end
|
5
|
-
|
6
|
-
describe '.enable' do
|
7
|
-
it 'enables all the things' do
|
8
|
-
expect(InstJobsStatsd::Stats::Periodic::Queue).to receive(:enable_queue_depth)
|
9
|
-
expect(InstJobsStatsd::Stats::Periodic::Queue).to receive(:enable_queue_age)
|
10
|
-
InstJobsStatsd::Stats::Periodic::Queue.enable
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '.report_queue_depth' do
|
15
|
-
let(:x) { Struct.new(:perform).new(true) }
|
16
|
-
let(:now) { Delayed::Job.db_time_now }
|
17
|
-
|
18
|
-
before do
|
19
|
-
InstJobsStatsd::Stats::Periodic::Queue.enable_queue_depth
|
20
|
-
|
21
|
-
x.delay.perform
|
22
|
-
Delayed::Job.first.update(locked_at: Delayed::Job.db_time_now, locked_by: 'test')
|
23
|
-
|
24
|
-
x.delay.perform
|
25
|
-
x.delay(run_at: now + 1.minute).perform
|
26
|
-
x.delay(run_at: now + 10.minutes).perform
|
27
|
-
end
|
28
|
-
|
29
|
-
it do
|
30
|
-
expect(InstStatsd::Statsd).to receive(:gauge)
|
31
|
-
.with(array_including(/\.queue_depth$/), 1, 1, { short_stat: anything, tags: {} })
|
32
|
-
InstJobsStatsd::Stats::Periodic::Queue.report_queue_depth
|
33
|
-
end
|
34
|
-
|
35
|
-
it do
|
36
|
-
expect(InstStatsd::Statsd).to receive(:gauge)
|
37
|
-
.with(array_including(/\.queue_depth$/), 2, 1, { short_stat: anything, tags: {} })
|
38
|
-
Timecop.freeze(2.minutes.from_now) do
|
39
|
-
InstJobsStatsd::Stats::Periodic::Queue.report_queue_depth
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
it do
|
44
|
-
expect(InstStatsd::Statsd).to receive(:gauge)
|
45
|
-
.with(array_including(/\.queue_depth$/), 3, 1, { short_stat: anything, tags: {} })
|
46
|
-
Timecop.freeze(20.minutes.from_now) do
|
47
|
-
InstJobsStatsd::Stats::Periodic::Queue.report_queue_depth
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '.report_queue_age' do
|
53
|
-
let(:x) { Struct.new(:perform).new(true) }
|
54
|
-
let(:now) { Delayed::Job.db_time_now }
|
55
|
-
|
56
|
-
before do
|
57
|
-
InstJobsStatsd::Stats::Periodic::Queue.enable_queue_age
|
58
|
-
|
59
|
-
x.delay.perform
|
60
|
-
Delayed::Job.first.update(locked_at: Delayed::Job.db_time_now, locked_by: 'test')
|
61
|
-
|
62
|
-
x.delay.perform
|
63
|
-
x.delay(run_at: now + 1.minute).perform
|
64
|
-
x.delay(run_at: now + 10.minutes).perform
|
65
|
-
end
|
66
|
-
|
67
|
-
it do
|
68
|
-
expect(InstStatsd::Statsd).to receive(:gauge)
|
69
|
-
.ordered.with(array_including(/\.queue_age_total$/), number_near(0), 1, { short_stat: anything, tags: {} })
|
70
|
-
expect(InstStatsd::Statsd).to receive(:gauge)
|
71
|
-
.ordered.with(array_including(/\.queue_age_max$/), number_near(0), 1, { short_stat: anything, tags: {} })
|
72
|
-
InstJobsStatsd::Stats::Periodic::Queue.report_queue_age
|
73
|
-
end
|
74
|
-
|
75
|
-
it do
|
76
|
-
expect(InstStatsd::Statsd).to receive(:gauge)
|
77
|
-
.ordered.with(array_including(/\.queue_age_total$/), number_near(180), 1, { short_stat: anything, tags: {} })
|
78
|
-
expect(InstStatsd::Statsd).to receive(:gauge)
|
79
|
-
.ordered.with(array_including(/\.queue_age_max$/), number_near(120), 1, { short_stat: anything, tags: {} })
|
80
|
-
Timecop.freeze(2.minutes.from_now) do
|
81
|
-
InstJobsStatsd::Stats::Periodic::Queue.report_queue_age
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
it do
|
86
|
-
expect(InstStatsd::Statsd).to receive(:gauge)
|
87
|
-
.ordered.with(array_including(/\.queue_age_total$/), number_near(2940), 1, { short_stat: anything, tags: {} })
|
88
|
-
expect(InstStatsd::Statsd).to receive(:gauge)
|
89
|
-
.ordered.with(array_including(/\.queue_age_max$/), number_near(1200), 1, { short_stat: anything, tags: {} })
|
90
|
-
Timecop.freeze(20.minutes.from_now) do
|
91
|
-
InstJobsStatsd::Stats::Periodic::Queue.report_queue_age
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|