inst-jobs-statsd 2.1.2 → 2.2.0
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 +2 -0
- data/lib/inst_jobs_statsd/jobs_tracker.rb +2 -0
- data/lib/inst_jobs_statsd/stats/counters/complete.rb +21 -0
- data/lib/inst_jobs_statsd/stats/counters/create.rb +21 -0
- data/lib/inst_jobs_statsd/version.rb +1 -1
- data/spec/inst_jobs_statsd/ext/job_spec.rb +4 -2
- data/spec/inst_jobs_statsd/jobs_tracker_spec.rb +2 -0
- data/spec/inst_jobs_statsd/stats/counters/complete_spec.rb +27 -0
- data/spec/inst_jobs_statsd/stats/counters/create_spec.rb +27 -0
- metadata +28 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10d4bb1c1c2d71c7a93df1ccd59657c96f871dd65b4e90ea7430fdf7b6da4991
|
4
|
+
data.tar.gz: f8af74f6d0e5abd4ec7f490ad592ee75c2909126574d889d275d7e8a2227df8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26f9240b397a8012fd8173c1a4658c53b7106eeecb4c2c833c82e2dc7963b4b73bb38bd442b469fcd551636f49c998daea5c8f7d7d929e5f7b3c0e1ac5361172
|
7
|
+
data.tar.gz: 8704615a3f54eed9d808930932ebb293818ab7af537bfc8e3a88cff6de685e3e6b3153342f643d1547f84f8a4c34b1181cc2d830cc3a91520b5e5e398d093d1c
|
data/lib/inst-jobs-statsd.rb
CHANGED
@@ -9,7 +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/create'
|
12
13
|
require_relative 'inst_jobs_statsd/stats/counters/run'
|
14
|
+
require_relative 'inst_jobs_statsd/stats/counters/complete'
|
13
15
|
|
14
16
|
require_relative 'inst_jobs_statsd/stats/periodic'
|
15
17
|
require_relative 'inst_jobs_statsd/stats/periodic/failed'
|
@@ -9,7 +9,9 @@ module InstJobsStatsd
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize(enable_periodic_queries: true)
|
12
|
+
Stats::Counters::Create.enable
|
12
13
|
Stats::Counters::Run.enable
|
14
|
+
Stats::Counters::Complete.enable
|
13
15
|
::Delayed::Job.prepend InstJobsStatsd::Ext::Job
|
14
16
|
|
15
17
|
if enable_periodic_queries
|
@@ -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
|
@@ -5,11 +5,13 @@ RSpec.describe 'InstJobsStatsd::Ext::Job' do
|
|
5
5
|
end
|
6
6
|
let(:x) { Struct.new(:perform).new(true) }
|
7
7
|
it 'sends a stat' do
|
8
|
-
|
9
|
-
.with(array_including(/\.failed$/), 1, 1, short_stat: :failed, tags: {})
|
8
|
+
allow(InstStatsd::Statsd).to receive(:count)
|
10
9
|
|
11
10
|
x.delay.perform
|
12
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: {})
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -12,7 +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::Create).to receive(:enable)
|
15
16
|
expect(InstJobsStatsd::Stats::Counters::Run).to receive(:enable)
|
17
|
+
expect(InstJobsStatsd::Stats::Counters::Complete).to receive(:enable)
|
16
18
|
|
17
19
|
expect(InstJobsStatsd::Stats::Periodic::Failed).to receive(:enable)
|
18
20
|
expect(InstJobsStatsd::Stats::Periodic::Queue).to receive(:enable)
|
@@ -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
|
metadata
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inst-jobs-statsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
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: 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:
|
19
|
+
version: 3.1.1
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '4.0'
|
@@ -24,9 +24,9 @@ dependencies:
|
|
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
32
|
version: '4.0'
|
@@ -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: []
|
@@ -245,6 +245,8 @@ files:
|
|
245
245
|
- lib/inst_jobs_statsd/jobs_tracker.rb
|
246
246
|
- lib/inst_jobs_statsd/naming.rb
|
247
247
|
- lib/inst_jobs_statsd/stats/counters.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
|
@@ -261,6 +263,8 @@ files:
|
|
261
263
|
- spec/inst_jobs_statsd/ext/job_spec.rb
|
262
264
|
- spec/inst_jobs_statsd/jobs_tracker_spec.rb
|
263
265
|
- spec/inst_jobs_statsd/naming_spec.rb
|
266
|
+
- spec/inst_jobs_statsd/stats/counters/complete_spec.rb
|
267
|
+
- spec/inst_jobs_statsd/stats/counters/create_spec.rb
|
264
268
|
- spec/inst_jobs_statsd/stats/counters/run_spec.rb
|
265
269
|
- spec/inst_jobs_statsd/stats/periodic/failed_spec.rb
|
266
270
|
- spec/inst_jobs_statsd/stats/periodic/queue_spec.rb
|
@@ -278,7 +282,7 @@ homepage: https://github.com/instructure/inst-jobs-statsd
|
|
278
282
|
licenses:
|
279
283
|
- MIT
|
280
284
|
metadata: {}
|
281
|
-
post_install_message:
|
285
|
+
post_install_message:
|
282
286
|
rdoc_options: []
|
283
287
|
require_paths:
|
284
288
|
- lib
|
@@ -293,27 +297,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
297
|
- !ruby/object:Gem::Version
|
294
298
|
version: '0'
|
295
299
|
requirements: []
|
296
|
-
rubygems_version: 3.
|
297
|
-
signing_key:
|
300
|
+
rubygems_version: 3.1.4
|
301
|
+
signing_key:
|
298
302
|
specification_version: 4
|
299
303
|
summary: Stats reporting for inst-jobs
|
300
304
|
test_files:
|
305
|
+
- spec/factories/jobs.rb
|
306
|
+
- spec/factories/workers.rb
|
307
|
+
- spec/gemfiles/60.gemfile
|
301
308
|
- spec/inst_jobs_statsd/ext/job_spec.rb
|
309
|
+
- spec/inst_jobs_statsd/jobs_tracker_spec.rb
|
302
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
|
303
314
|
- spec/inst_jobs_statsd/stats/periodic/failed_spec.rb
|
304
|
-
- spec/inst_jobs_statsd/stats/periodic/run_spec.rb
|
305
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
|
306
318
|
- spec/inst_jobs_statsd/stats/timing/failed_spec.rb
|
307
|
-
- spec/inst_jobs_statsd/stats/timing/pop_spec.rb
|
308
319
|
- spec/inst_jobs_statsd/stats/timing/perform_spec.rb
|
309
|
-
- spec/inst_jobs_statsd/stats/
|
310
|
-
- spec/inst_jobs_statsd/stats/counters/run_spec.rb
|
320
|
+
- spec/inst_jobs_statsd/stats/timing/pop_spec.rb
|
311
321
|
- spec/inst_jobs_statsd/stats/timing_spec.rb
|
312
|
-
- spec/inst_jobs_statsd/jobs_tracker_spec.rb
|
313
|
-
- spec/spec_helper.rb
|
314
|
-
- spec/setup_test_db.rb
|
315
|
-
- spec/matchers.rb
|
316
|
-
- spec/gemfiles/60.gemfile
|
317
|
-
- spec/factories/workers.rb
|
318
|
-
- spec/factories/jobs.rb
|
319
322
|
- spec/inst_statsd/default_tracking_spec.rb
|
323
|
+
- spec/matchers.rb
|
324
|
+
- spec/setup_test_db.rb
|
325
|
+
- spec/spec_helper.rb
|