roqua-support 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +0 -0
  3. data/.travis.yml +0 -0
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +1 -0
  6. data/Gemfile.lock +2 -1
  7. data/LICENSE.txt +0 -0
  8. data/circle.yml +0 -0
  9. data/lib/roqua-support/version.rb +1 -1
  10. data/lib/roqua/core_ext/active_interaction/filters/date_time_as_unix_extension.rb +0 -0
  11. data/lib/roqua/core_ext/active_interaction/filters/duration_filter.rb +0 -0
  12. data/lib/roqua/core_ext/active_interaction/rails_instrumentation.rb +0 -0
  13. data/lib/roqua/core_ext/activerecord/uniq_find_or_create.rb +0 -0
  14. data/lib/roqua/core_ext/enumerable/sort_by_alphanum.rb +0 -0
  15. data/lib/roqua/core_ext/fabrication/singleton.rb +0 -0
  16. data/lib/roqua/probes/base_probe.rb +16 -4
  17. data/lib/roqua/probes/delayed_job_probe.rb +2 -2
  18. data/lib/roqua/probes/monitoring_probe.rb +2 -2
  19. data/lib/roqua/probes/scheduling_probe.rb +2 -2
  20. data/lib/roqua/responders/active_interaction_aware_responder.rb +0 -0
  21. data/lib/roqua/responders/api_errors_responder.rb +0 -0
  22. data/lib/roqua/scheduling/scheduler.rb +1 -0
  23. data/lib/roqua/support/command_runner.rb +0 -0
  24. data/lib/roqua/support/instrumentation.rb +0 -0
  25. data/lib/roqua/support/log_wrapper.rb +0 -0
  26. data/lib/roqua/support/request_logger.rb +0 -0
  27. data/lib/roqua/support/stats.rb +0 -0
  28. data/lib/roqua/support/stats/hosted_graphite_backend.rb +0 -0
  29. data/lib/roqua/validators/subset_validator.rb +0 -0
  30. data/spec/roqua/core_ext/active_interaction/date_time_as_unix_extension_spec.rb +0 -0
  31. data/spec/roqua/core_ext/active_interaction/duration_filter_spec.rb +0 -0
  32. data/spec/roqua/core_ext/active_interaction/rails_intrumentation_spec.rb +0 -0
  33. data/spec/roqua/probes/delayed_job_probe_spec.rb +7 -2
  34. data/spec/roqua/probes/monitoring_probe_spec.rb +8 -3
  35. data/spec/roqua/responders/active_interaction_aware_responder_spec.rb +0 -0
  36. data/spec/roqua/responders/api_errors_responder_spec.rb +0 -0
  37. data/spec/roqua/scheduling/scheduler_spec.rb +8 -1
  38. data/spec/roqua/support/stats_spec.rb +0 -0
  39. data/spec/roqua/validators/subset_validator_spec.rb +0 -0
  40. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b7684543b65ccc1553042df3e832dba5f40a8f42d0ff15fa31f42d865755b32
4
- data.tar.gz: 3ba17388d2c2b947756ddb1ca3b4172a6bcbde85bef76b0c70a5eb9fe7fe16d5
3
+ metadata.gz: e5997425ea5b975ef1adf4b17e10d3d6c44bbdaa6507f696db1a5aad1ddf9513
4
+ data.tar.gz: cc565728bb3fc02e707b92d8ab507c996a793f9c6d5d16b0e6d8cfed1462ae70
5
5
  SHA512:
6
- metadata.gz: 880ee19112ad1e4f596a451228b7b3b6f5b07ad381f0d1706ee00c42b070af2c8dd3048a26363183c09ba9ceb2f7e34c72b3289b11f8829ee0e02a613e173742
7
- data.tar.gz: fa8da4fcb52839b129019a08f4ba852cc629af98944c9aef9add34c4ef2244ace706e59f53765b551c95da8a6231bed7a096afeb0e4dacfa7e7a1d02a5f14f17
6
+ metadata.gz: c9fc30367ece67f45800e8ab586f86f8aed50f8033be899265c5a03a87318ebdb960b87652c69dbb03da28c419242dffa1aa6977e82708b6e33a3b9ff445c352
7
+ data.tar.gz: 28c2f803f644b2244908cc52b5326074298e81b31c8e0f3f9cd6ac9a422dab00e51ac3d1e4383f2b09516fdc045bafe6b52cde2e3cf22353608d284ce9e046d9
data/.rspec CHANGED
File without changes
File without changes
@@ -1,3 +1,7 @@
1
+ ## 0.3.1
2
+
3
+ * Added Appsignal counters for probe calls and scheduling probe call tasks in particular.
4
+
1
5
  ## 0.3.0
2
6
 
3
7
  * Support for Ruby 2.5
data/Gemfile CHANGED
@@ -17,4 +17,5 @@ group :test do
17
17
  gem 'responders'
18
18
  gem 'rspec-instrumentation-matcher'
19
19
  gem 'rspec-rails'
20
+ gem 'pry'
20
21
  end
@@ -188,6 +188,7 @@ DEPENDENCIES
188
188
  delayed_job_active_record
189
189
  fakefs
190
190
  guard-rspec (~> 4.2.6)
191
+ pry
191
192
  rake
192
193
  responders
193
194
  roqua-support!
@@ -199,4 +200,4 @@ DEPENDENCIES
199
200
  timecop
200
201
 
201
202
  BUNDLED WITH
202
- 1.16.6
203
+ 1.17.3
File without changes
data/circle.yml CHANGED
File without changes
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module Support
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.3.1'.freeze
4
4
  end
5
5
  end
@@ -1,12 +1,24 @@
1
+ require 'active_support/concern'
2
+
1
3
  module Roqua
2
4
  module Probes
3
5
  module BaseProbe
4
- def enable
5
- new.tap do |probe|
6
- probe_sym = probe.class.to_s.to_sym
7
- Appsignal::Minutely.probes.register(probe_sym, probe) unless Appsignal::Minutely.probes[probe_sym]
6
+ extend ActiveSupport::Concern
7
+
8
+ class_methods do
9
+ def enable
10
+ new.tap do |probe|
11
+ probe_sym = probe.class.to_s.to_sym
12
+ Appsignal::Minutely.probes.register(probe_sym, probe) unless Appsignal::Minutely.probes[probe_sym]
13
+ end
8
14
  end
9
15
  end
16
+
17
+ # do not override me, implement probes by implementing the #run method
18
+ def call
19
+ run
20
+ Appsignal.increment_counter("probe.call.completed.#{self.class.name.demodulize.underscore}", 1)
21
+ end
10
22
  end
11
23
  end
12
24
  end
@@ -3,13 +3,13 @@ require_relative 'base_probe'
3
3
  module Roqua
4
4
  module Probes
5
5
  class DelayedJobProbe
6
- extend BaseProbe
6
+ include BaseProbe
7
7
 
8
8
  def backlog_count
9
9
  Delayed::Job.where(locked_at: nil).where('run_at < ?', Time.zone.now).count
10
10
  end
11
11
 
12
- def call
12
+ def run
13
13
  Appsignal.set_gauge('delayed_job_backlog_count', backlog_count)
14
14
  end
15
15
  end
@@ -3,7 +3,7 @@ require_relative 'base_probe'
3
3
  module Roqua
4
4
  module Probes
5
5
  class MonitoringProbe
6
- extend BaseProbe
6
+ include BaseProbe
7
7
 
8
8
  def incomplete_jobs
9
9
  Roqua::Scheduling::CronJob.where('completed_at IS NULL OR completed_at < next_run_at')
@@ -19,7 +19,7 @@ module Roqua
19
19
  (longest_delay_in_seconds / 1.minute).to_i
20
20
  end
21
21
 
22
- def call
22
+ def run
23
23
  Appsignal.set_gauge('scheduler_delay_in_minutes', longest_delay_in_minutes)
24
24
  end
25
25
  end
@@ -3,9 +3,9 @@ require_relative 'base_probe'
3
3
  module Roqua
4
4
  module Probes
5
5
  class SchedulingProbe
6
- extend BaseProbe
6
+ include BaseProbe
7
7
 
8
- def call
8
+ def run
9
9
  ActiveRecord::Base.establish_connection
10
10
  require_relative Rails.root.join('config', 'schedule.rb')
11
11
  Roqua::Scheduling::Scheduler.new.ping
@@ -42,6 +42,7 @@ class Roqua::Scheduling::Scheduler
42
42
  task = schedule.tasks[cron_job.name]
43
43
  task.run
44
44
 
45
+ Appsignal.increment_counter("scheduler.run_task.completed.#{task.name}", 1)
45
46
  cron_job.update completed_at: Time.now, next_run_at: task.next_run_at
46
47
  end
47
48
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -7,7 +7,7 @@ require 'roqua/probes/delayed_job_probe'
7
7
  describe Roqua::Probes::DelayedJobProbe do
8
8
  before { Timecop.freeze }
9
9
  after { Timecop.return }
10
- subject(:probe) { Roqua::Probes::DelayedJobProbe.new }
10
+ subject(:probe) { described_class.new }
11
11
 
12
12
  describe 'backlog_count' do
13
13
  context 'if a single job unlocked job exists that has a run_at in the past' do
@@ -24,12 +24,17 @@ describe Roqua::Probes::DelayedJobProbe do
24
24
  end
25
25
  end
26
26
 
27
- describe 'call' do
27
+ describe '#call' do
28
28
  it 'sends the correct metric to Appsignal' do
29
29
  expect(probe).to receive(:backlog_count).and_return(12)
30
30
  expect(Appsignal).to receive(:set_gauge).with('delayed_job_backlog_count', 12)
31
31
  probe.call
32
32
  end
33
+
34
+ it 'increments the probe call counter' do
35
+ expect(Appsignal).to receive(:increment_counter).with('probe.call.completed.delayed_job_probe', 1)
36
+ probe.call
37
+ end
33
38
  end
34
39
 
35
40
  context '.enable' do
@@ -4,21 +4,26 @@ require 'timecop'
4
4
 
5
5
  require 'roqua/probes/delayed_job_probe'
6
6
 
7
- describe Roqua::Probes::DelayedJobProbe do
7
+ describe Roqua::Probes::MonitoringProbe do
8
8
  before { Timecop.freeze }
9
9
  after { Timecop.return }
10
- subject(:probe) { Roqua::Probes::MonitoringProbe.new }
10
+ subject(:probe) { described_class.new }
11
11
 
12
12
  before do
13
13
  Roqua::Scheduling::CronJob.delete_all
14
14
  end
15
15
 
16
- describe 'call' do
16
+ describe '#call' do
17
17
  it 'sends data to AppSignal' do
18
18
  expect(Appsignal).to receive(:set_gauge).with('scheduler_delay_in_minutes', 10)
19
19
  expect(probe).to receive(:longest_delay_in_minutes).and_return(10)
20
20
  probe.call
21
21
  end
22
+
23
+ it 'increments the probe call counter' do
24
+ expect(Appsignal).to receive(:increment_counter).with('probe.call.completed.monitoring_probe', 1)
25
+ probe.call
26
+ end
22
27
  end
23
28
 
24
29
  describe 'longest_delay' do
@@ -72,16 +72,23 @@ describe Roqua::Scheduling::Scheduler do
72
72
  describe 'callbacks' do
73
73
  let(:callback_spy) { spy(:callback) }
74
74
 
75
- it 'get executed' do
75
+ before do
76
76
  Roqua::Scheduling::Schedule.setup do |cron|
77
77
  cron.add_task 'hourly', next_run_at: proc { 1.minute.ago } do
78
78
  callback_spy.execute
79
79
  end
80
80
  end
81
+ end
81
82
 
83
+ it 'get executed' do
82
84
  expect(callback_spy).to receive(:execute)
83
85
  subject.ping
84
86
  end
87
+
88
+ it 'counts task calls' do
89
+ expect(Appsignal).to receive(:increment_counter).with('scheduler.run_task.completed.hourly', 1)
90
+ subject.ping
91
+ end
85
92
  end
86
93
 
87
94
  describe 'when running multiple times' do
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_interaction
@@ -281,8 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  - !ruby/object:Gem::Version
282
282
  version: '0'
283
283
  requirements: []
284
- rubyforge_project:
285
- rubygems_version: 2.7.9
284
+ rubygems_version: 3.0.3
286
285
  signing_key:
287
286
  specification_version: 4
288
287
  summary: Helper objects and proxies used by a lot of RoQua applications