Skip to content

Commit

Permalink
Add a Sidekiq retry size check
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleese committed Jul 12, 2018
1 parent 243be6e commit f60495b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
18 changes: 18 additions & 0 deletions docs/healthchecks.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,21 @@ class MySidekiqQueueSizeCheck < GovukHealthcheck::SidekiqQueueSizeCheck
end
end
```


### `SidekiqRetrySizeCheck`

Similar to `SidekiqQueueSizeCheck`, this class is the basis for a check which
compares the Sidekiq retry set size with a warning and critical threshold.

```ruby
class MySidekiqRetrySizeCheck < GovukHealthcheck::SidekiqRetrySizeCheck
def warning_threshold
# the warning threshold for the retry set
end

def critical_threshold
# the critical threshold for the retry set
end
end
```
3 changes: 2 additions & 1 deletion lib/govuk_app_config/govuk_healthcheck.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
require "govuk_app_config/govuk_healthcheck/checkup"
require "govuk_app_config/govuk_healthcheck/active_record"
require "govuk_app_config/govuk_healthcheck/sidekiq_redis"
require "govuk_app_config/govuk_healthcheck/threshold_check"
require "govuk_app_config/govuk_healthcheck/sidekiq_queue_check"
require "govuk_app_config/govuk_healthcheck/sidekiq_queue_latency_check"
require "govuk_app_config/govuk_healthcheck/sidekiq_queue_size_check"
require "govuk_app_config/govuk_healthcheck/threshold_check"
require "govuk_app_config/govuk_healthcheck/sidekiq_retry_size_check"
require "json"

module GovukHealthcheck
Expand Down
11 changes: 11 additions & 0 deletions lib/govuk_app_config/govuk_healthcheck/sidekiq_retry_size_check.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module GovukHealthcheck
class SidekiqRetrySizeCheck < ThresholdCheck
def name
:sidekiq_retry_size
end

def value
Sidekiq::Stats.new.retry_size
end
end
end
27 changes: 27 additions & 0 deletions spec/lib/govuk_healthcheck/sidekiq_retry_size_check_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "spec_helper"
require "govuk_app_config/govuk_healthcheck"
require_relative "shared_interface"

RSpec.describe GovukHealthcheck::SidekiqRetrySizeCheck do
subject { TestRetrySizeCheck.new }

let(:sidekiq_stats) { double(retry_size: 10) }
let(:sidekiq_stats_class) { double }

before do
allow(sidekiq_stats_class).to receive(:new).and_return(sidekiq_stats)
stub_const("Sidekiq::Stats", sidekiq_stats_class)
end

it_behaves_like "a healthcheck"

class TestRetrySizeCheck < GovukHealthcheck::SidekiqRetrySizeCheck
def warning_threshold
10
end

def critical_threshold
20
end
end
end

0 comments on commit f60495b

Please sign in to comment.