govuk_app_config 2.10.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f98f57ba0b9010154d3aefbc2540acd056d35ef42af9e3b22b00495255f46899
4
- data.tar.gz: c5315e4ba1f476e7c0fcb99839ad9e8705a1546e4b48e3246a16e94f6552b383
3
+ metadata.gz: 68431d222e7798dd3027131ef5d05ea7cfab1f7df54d5e06274f2de19f4e51ea
4
+ data.tar.gz: 6c5273bd18e606f6269279d547e91630574d61dc7a1151bfbbecd55f3f38d371
5
5
  SHA512:
6
- metadata.gz: cea414c28b13d2b9cb359bade9dd6626eceb9dfd0f76ca79f77b2b8bff9f4807c01858951860e6888f795a32aa50cd2c79cc1ea63f72a01315a6cbd44b49d8cd
7
- data.tar.gz: 3ef1e0ea53a489935775c9475cecb5f55585d2cfba0aed30b6a184430ab7fada8e24670150ebfa60043a59a6d750f76aeb913b89f826da2bbe3db68ca524cc7a
6
+ metadata.gz: '06387b0c49fe60c29728fdda8a8f3bfe529c9b8db2b87ef795b20dfb2ef157667102768d496a7cb1ccad4425265051075f9886d9e155632bb68c47626480c882'
7
+ data.tar.gz: 4ec51524d66f98be80b779d28ec65d0355b721e2fd794c03f4c61a573371c800e46f6d7c6ee514dd080430763803f7396bcd37c0e4bd7e57d33d886f6ae59980
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 3.0.0
2
+
3
+ * BREAKING: Implement RFC 141 - remove unsuitable healthchecks and return a 500 on healthcheck failure ([#193](https://github.com/alphagov/govuk_app_config/pull/193))
4
+
1
5
  # 2.10.0
2
6
  * Allow LUX domain on img-src policy ([#191](https://github.com/alphagov/govuk_app_config/pull/191))
3
7
 
@@ -4,19 +4,16 @@ require "govuk_app_config/govuk_healthcheck/mongoid"
4
4
  require "govuk_app_config/govuk_healthcheck/rails_cache"
5
5
  require "govuk_app_config/govuk_healthcheck/redis"
6
6
  require "govuk_app_config/govuk_healthcheck/sidekiq_redis"
7
- require "govuk_app_config/govuk_healthcheck/threshold_check"
8
- require "govuk_app_config/govuk_healthcheck/sidekiq_queue_check"
9
- require "govuk_app_config/govuk_healthcheck/sidekiq_queue_latency_check"
10
- require "govuk_app_config/govuk_healthcheck/sidekiq_retry_size_check"
11
7
  require "json"
12
8
 
13
9
  module GovukHealthcheck
14
10
  def self.rack_response(*checks)
15
11
  proc do
12
+ checkup = healthcheck(checks)
16
13
  [
17
- 200,
14
+ checkup[:status] == :ok ? 200 : 500,
18
15
  { "Content-Type" => "application/json" },
19
- [JSON.dump(healthcheck(checks))],
16
+ [JSON.dump(checkup)],
20
17
  ]
21
18
  end
22
19
  end
@@ -1,3 +1,3 @@
1
1
  module GovukAppConfig
2
- VERSION = "2.10.0".freeze
2
+ VERSION = "3.0.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_app_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-25 00:00:00.000000000 Z
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstasher
@@ -237,11 +237,7 @@ files:
237
237
  - lib/govuk_app_config/govuk_healthcheck/mongoid.rb
238
238
  - lib/govuk_app_config/govuk_healthcheck/rails_cache.rb
239
239
  - lib/govuk_app_config/govuk_healthcheck/redis.rb
240
- - lib/govuk_app_config/govuk_healthcheck/sidekiq_queue_check.rb
241
- - lib/govuk_app_config/govuk_healthcheck/sidekiq_queue_latency_check.rb
242
240
  - lib/govuk_app_config/govuk_healthcheck/sidekiq_redis.rb
243
- - lib/govuk_app_config/govuk_healthcheck/sidekiq_retry_size_check.rb
244
- - lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
245
241
  - lib/govuk_app_config/govuk_i18n.rb
246
242
  - lib/govuk_app_config/govuk_logging.rb
247
243
  - lib/govuk_app_config/govuk_statsd.rb
@@ -1,62 +0,0 @@
1
- module GovukHealthcheck
2
- class SidekiqQueueCheck
3
- def status
4
- queues.each do |name, value|
5
- if value >= critical_threshold(queue: name)
6
- return :critical
7
- elsif value >= warning_threshold(queue: name)
8
- return :warning
9
- end
10
- end
11
-
12
- :ok
13
- end
14
-
15
- def message
16
- messages = queues.map do |name, value|
17
- critical = critical_threshold(queue: name)
18
- warning = warning_threshold(queue: name)
19
-
20
- if value >= critical
21
- "#{name} (#{value}) is above the critical threshold (#{critical})"
22
- elsif value >= warning
23
- "#{name} (#{value}) is above the warning threshold (#{warning})"
24
- end
25
- end
26
-
27
- messages = messages.compact
28
-
29
- if messages.empty?
30
- "all queues are below the critical and warning thresholds"
31
- else
32
- messages.join("\n")
33
- end
34
- end
35
-
36
- def details
37
- {
38
- queues: queues.each_with_object({}) do |(name, value), hash|
39
- hash[name] = {
40
- value: value,
41
- thresholds: {
42
- critical: critical_threshold(queue: name),
43
- warning: warning_threshold(queue: name),
44
- }.reject { |_, val| val.to_f.infinite? || val.to_f.nan? },
45
- }
46
- end,
47
- }
48
- end
49
-
50
- def queues
51
- raise "This method must be overriden to be a hash of queue names and data."
52
- end
53
-
54
- def critical_threshold(queue:) # rubocop:disable Lint/UnusedMethodArgument
55
- raise "This method must be overriden to be the critical threshold."
56
- end
57
-
58
- def warning_threshold(queue:) # rubocop:disable Lint/UnusedMethodArgument
59
- raise "This method must be overriden to be the warning threshold."
60
- end
61
- end
62
- end
@@ -1,13 +0,0 @@
1
- module GovukHealthcheck
2
- class SidekiqQueueLatencyCheck < SidekiqQueueCheck
3
- def name
4
- :sidekiq_queue_latency
5
- end
6
-
7
- def queues
8
- @queues ||= Sidekiq::Stats.new.queues.keys.each_with_object({}) do |name, hash|
9
- hash[name] = Sidekiq::Queue.new(name).latency
10
- end
11
- end
12
- end
13
- end
@@ -1,11 +0,0 @@
1
- module GovukHealthcheck
2
- class SidekiqRetrySizeCheck < ThresholdCheck
3
- def name
4
- :sidekiq_retry_size
5
- end
6
-
7
- def value
8
- Sidekiq::Stats.new.retry_size
9
- end
10
- end
11
- end
@@ -1,50 +0,0 @@
1
- module GovukHealthcheck
2
- class ThresholdCheck
3
- def status
4
- if value >= critical_threshold
5
- :critical
6
- elsif value >= warning_threshold
7
- :warning
8
- else
9
- :ok
10
- end
11
- end
12
-
13
- def message
14
- if value >= critical_threshold
15
- "#{value} is above the critical threshold (#{critical_threshold})"
16
- elsif value >= warning_threshold
17
- "#{value} is above the warning threshold (#{warning_threshold})"
18
- else
19
- "#{value} is below the critical and warning thresholds"
20
- end
21
- end
22
-
23
- def details
24
- {
25
- value: value,
26
- total: total,
27
- thresholds: {
28
- critical: critical_threshold,
29
- warning: warning_threshold,
30
- },
31
- }
32
- end
33
-
34
- def value
35
- raise "This method must be overridden to be the check value."
36
- end
37
-
38
- def total
39
- nil # This method can be overriden to provide the total for the check.
40
- end
41
-
42
- def critical_threshold
43
- raise "This method must be overriden to be the critical threshold."
44
- end
45
-
46
- def warning_threshold
47
- raise "This method must be overriden to be the warning threshold."
48
- end
49
- end
50
- end