health-monitor-rails 9.3.0 → 9.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fefcb47918931ba220666f67809857de73b45f8ccbb07611bcceb8ffd5661cb
4
- data.tar.gz: 6002b738f3b4c8ed4cd1f6d9d07fc55b218a71bf04a0a0c53fcef8bd1a8b2369
3
+ metadata.gz: 4e3901481f04e5dbca447ec01e0e551dc0d6788b82e48ecc681fdf598f7d1094
4
+ data.tar.gz: 1fb26a9ff50047e499d810834b0c44b354d23e5587dabb9d8da7d6dca2e7fa85
5
5
  SHA512:
6
- metadata.gz: 1b0e752bee2272ab5b708a2073e5b3385c71c2003db2886849ab648928b8324caa8bfbf3738f494c6313bfba3bbb08a6f54b5ee39794efac4a517444d02e8521
7
- data.tar.gz: 7dbe3909de4048a29a9395c84da5ae6ed58d2971379d03352db5b47a00b7dda8a01e313462cb591badd207e58bb878ee8b36b76acd39cf596d5db53dcb95c523
6
+ metadata.gz: 2074e27e809d298e5b65eeef3d8a3c8b6215ae530f056a66cec0d8f561bdf04e45cefa62f5e7af14f5dc2457bd6823db671ff4ce8fdbd6aa6ccde486bb67c0d9
7
+ data.tar.gz: b62478c0bbcbd00295ab63a4846397ace4882d49508385faeb7cd794e3f09b1127a532603320c1567727882965cd840b59352a537913a488119bb8ee238a58c3
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # health-monitor-rails
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/health-monitor-rails.svg)](http://badge.fury.io/rb/health-monitor-rails)
4
- [![Build Status](https://travis-ci.com/lbeder/health-monitor-rails.svg?branch=master)](https://travis-ci.com/lbeder/health-monitor-rails)
4
+ [![Build Status](https://github.com/lbeder/health-monitor-rails/actions/workflows/ci.yml/badge.svg)](https://github.com/lbeder/health-monitor-rails/actions/workflows/ci.yml)
5
5
  [![Coverage Status](https://coveralls.io/repos/lbeder/health-monitor-rails/badge.svg)](https://coveralls.io/r/lbeder/health-monitor-rails)
6
6
 
7
7
  This is a health monitoring Rails mountable plug-in, which checks various services (db, cache, sidekiq, redis, etc.).
@@ -12,6 +12,7 @@ module HealthMonitor
12
12
 
13
13
  def check
14
14
  @statuses = statuses
15
+ @hide_footer = HealthMonitor.configuration.hide_footer
15
16
 
16
17
  respond_to do |format|
17
18
  format.html
@@ -69,10 +69,12 @@
69
69
  </div>
70
70
  </div>
71
71
  </main>
72
- <footer>
73
- <div class="font-light text-center text-slate-500 text-xs px-5">
74
- Powered by <a href="https://github.com/lbeder/health-monitor-rails" target="_blank">health-monitor-rails</a>
75
- </div>
76
- </footer>
72
+ <% if !@hide_footer %>
73
+ <footer>
74
+ <div class="font-light text-center text-slate-500 text-xs px-5">
75
+ Powered by <a href="https://github.com/lbeder/health-monitor-rails" target="_blank">health-monitor-rails</a>
76
+ </div>
77
+ </footer>
78
+ <% end %>
77
79
  </body>
78
80
  </html>
@@ -7,6 +7,7 @@ module HealthMonitor
7
7
  attr_accessor :basic_auth_credentials,
8
8
  :environment_variables,
9
9
  :error_callback,
10
+ :hide_footer,
10
11
  :path
11
12
  attr_reader :providers
12
13
 
@@ -21,7 +22,11 @@ module HealthMonitor
21
22
  PROVIDERS.each do |provider_name|
22
23
  define_method provider_name do |&_block|
23
24
  require "health_monitor/providers/#{provider_name}"
24
- add_provider("HealthMonitor::Providers::#{provider_name.to_s.titleize.delete(' ')}".constantize)
25
+
26
+ add_provider(
27
+ "HealthMonitor::Providers::#{provider_name.to_s.titleize.delete(' ')}"
28
+ .constantize
29
+ )
25
30
  end
26
31
  end
27
32
 
@@ -3,6 +3,8 @@
3
3
  module HealthMonitor
4
4
  module Providers
5
5
  class Base
6
+ @global_configuration = nil
7
+
6
8
  attr_reader :request
7
9
  attr_accessor :configuration
8
10
 
@@ -10,10 +12,14 @@ module HealthMonitor
10
12
  @provider_name ||= name.demodulize
11
13
  end
12
14
 
15
+ def self.global_configuration
16
+ @global_configuration ||= configuration_class.new
17
+ end
18
+
13
19
  def self.configure
14
20
  return unless configurable?
15
21
 
16
- @global_configuration = configuration_class.new
22
+ @global_configuration ||= configuration_class.new
17
23
 
18
24
  yield @global_configuration if block_given?
19
25
  end
@@ -23,7 +29,7 @@ module HealthMonitor
23
29
 
24
30
  return unless self.class.configurable?
25
31
 
26
- self.configuration = self.class.instance_variable_get('@global_configuration')
32
+ self.configuration = self.class.global_configuration
27
33
  end
28
34
 
29
35
  # @abstract
@@ -4,6 +4,8 @@ require 'health_monitor/providers/base'
4
4
 
5
5
  module HealthMonitor
6
6
  module Providers
7
+ CONNECTION_POOL_SIZE = 1
8
+
7
9
  class RedisException < StandardError; end
8
10
 
9
11
  class Redis < Base
@@ -23,6 +25,10 @@ module HealthMonitor
23
25
  def configuration_class
24
26
  ::HealthMonitor::Providers::Redis::Configuration
25
27
  end
28
+
29
+ def as_connection_pool(connection)
30
+ ConnectionPool.new(size: CONNECTION_POOL_SIZE) { connection }
31
+ end
26
32
  end
27
33
 
28
34
  def check!
@@ -30,8 +36,6 @@ module HealthMonitor
30
36
  check_max_used_memory!
31
37
  rescue Exception => e
32
38
  raise RedisException.new(e.message)
33
- ensure
34
- redis.close
35
39
  end
36
40
 
37
41
  private
@@ -39,8 +43,8 @@ module HealthMonitor
39
43
  def check_values!
40
44
  time = Time.now.to_formatted_s(:rfc2822)
41
45
 
42
- redis.set(key, time)
43
- fetched = redis.get(key)
46
+ redis.with { |conn| conn.set(key, time) }
47
+ fetched = redis.with { |conn| conn.get(key) }
44
48
 
45
49
  raise "different values (now: #{time}, fetched: #{fetched})" if fetched != time
46
50
  end
@@ -59,11 +63,15 @@ module HealthMonitor
59
63
  def redis
60
64
  @redis =
61
65
  if configuration.connection
62
- configuration.connection
66
+ if configuration.connection.is_a?(ConnectionPool)
67
+ configuration.connection
68
+ else
69
+ ConnectionPool.new(size: CONNECTION_POOL_SIZE) { configuration.connection }
70
+ end
63
71
  elsif configuration.url
64
- ::Redis.new(url: configuration.url)
72
+ ConnectionPool.new(size: CONNECTION_POOL_SIZE) { ::Redis.new(url: configuration.url) }
65
73
  else
66
- ::Redis.new
74
+ ConnectionPool.new(size: CONNECTION_POOL_SIZE) { ::Redis.new }
67
75
  end
68
76
  end
69
77
 
@@ -72,7 +80,7 @@ module HealthMonitor
72
80
  end
73
81
 
74
82
  def used_memory_mb
75
- bytes_to_megabytes(redis.info['used_memory'])
83
+ bytes_to_megabytes(redis.with { |conn| conn.info['used_memory'] })
76
84
  end
77
85
  end
78
86
  end
@@ -73,6 +73,7 @@ module HealthMonitor
73
73
 
74
74
  def check_processes!
75
75
  sidekiq_stats = ::Sidekiq::Stats.new
76
+
76
77
  return unless sidekiq_stats.processes_size.zero?
77
78
 
78
79
  raise 'Sidekiq alive processes number is 0!'
@@ -89,6 +90,7 @@ module HealthMonitor
89
90
  def check_queue_size!
90
91
  configuration.queues.each do |queue, config|
91
92
  size = queue(queue).size
93
+
92
94
  raise "queue '#{queue}': size #{size} is greater than #{config[:queue_size]}" if size > config[:queue_size]
93
95
  end
94
96
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HealthMonitor
4
- VERSION = '9.3.0'
4
+ VERSION = '9.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: health-monitor-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.3.0
4
+ version: 9.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Beder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-15 00:00:00.000000000 Z
11
+ date: 2022-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: coveralls
70
+ name: coveralls_reborn
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '4.1'
111
111
  - !ruby/object:Gem::Dependency
112
- name: pry
112
+ name: mock_redis
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: rake
126
+ name: pry
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -137,19 +137,19 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: rediska
140
+ name: rake
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 1.1.0
145
+ version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: 1.1.0
152
+ version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: resque
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -184,14 +184,42 @@ dependencies:
184
184
  requirements:
185
185
  - - ">="
186
186
  - !ruby/object:Gem::Version
187
- version: '0.5'
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rubocop-rake
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
188
202
  type: :development
189
203
  prerelease: false
190
204
  version_requirements: !ruby/object:Gem::Requirement
191
205
  requirements:
192
206
  - - ">="
193
207
  - !ruby/object:Gem::Version
194
- version: '0.5'
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rubocop-rspec
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
195
223
  - !ruby/object:Gem::Dependency
196
224
  name: sidekiq
197
225
  requirement: !ruby/object:Gem::Requirement