health-monitor-rails 9.4.0 → 10.1.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 +4 -4
 - data/README.md +16 -3
 - data/lib/health_monitor/providers/database.rb +9 -2
 - data/lib/health_monitor/providers/sidekiq.rb +9 -0
 - data/lib/health_monitor/version.rb +1 -1
 - metadata +4 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f31145948d53277b016035e3dd3b1580ccc47afc452f2a9a197141c3c96b21ad
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 80f759c330d6086287abd668c6c9bf5c9666092a3ac2d8ac2f0a8439981a36ff
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c3b4d89aa49a1d799f23ec6e98bf718a584e8c7954e1c4544d61159f0ed012609bb8eb213714cf987f52a537dd00c14bfbce6b92fa8f5f7e64b50fdf1f94310f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6e1f95ccc047a279d7cb8658a3186de8b20ae62260ea9832beec3ca7a944522b1a91171ee3aa9c4d9ddc672f964d8c55f2f8005a036d0423281d42dc038d34a0
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -214,7 +214,7 @@ HealthMonitor.configure do |config| 
     | 
|
| 
       214 
214 
     | 
    
         
             
              end
         
     | 
| 
       215 
215 
     | 
    
         
             
            end
         
     | 
| 
       216 
216 
     | 
    
         | 
| 
       217 
     | 
    
         
            -
            #  
     | 
| 
      
 217 
     | 
    
         
            +
            # Sidekiq with specific queues
         
     | 
| 
       218 
218 
     | 
    
         
             
            HealthMonitor.configure do |config|
         
     | 
| 
       219 
219 
     | 
    
         
             
              config.sidekiq.configure do |sidekiq_config|
         
     | 
| 
       220 
220 
     | 
    
         
             
                sidekiq_config.add_queue_configuration('critical', latency: 10.seconds, queue_size: 20)
         
     | 
| 
         @@ -224,7 +224,7 @@ end 
     | 
|
| 
       224 
224 
     | 
    
         
             
            ```
         
     | 
| 
       225 
225 
     | 
    
         | 
| 
       226 
226 
     | 
    
         
             
            ```ruby
         
     | 
| 
       227 
     | 
    
         
            -
            # Redis
         
     | 
| 
      
 227 
     | 
    
         
            +
            # Redis with existing connection
         
     | 
| 
       228 
228 
     | 
    
         
             
            HealthMonitor.configure do |config|
         
     | 
| 
       229 
229 
     | 
    
         
             
              config.redis.configure do |redis_config|
         
     | 
| 
       230 
230 
     | 
    
         
             
                redis_config.connection = Redis.current # Use your custom redis connection
         
     | 
| 
         @@ -236,7 +236,7 @@ end 
     | 
|
| 
       236 
236 
     | 
    
         
             
            Additionally, you can configure an explicit URL:
         
     | 
| 
       237 
237 
     | 
    
         | 
| 
       238 
238 
     | 
    
         
             
            ```ruby
         
     | 
| 
       239 
     | 
    
         
            -
            # Redis
         
     | 
| 
      
 239 
     | 
    
         
            +
            # Redis with a URL configuration
         
     | 
| 
       240 
240 
     | 
    
         
             
            HealthMonitor.configure do |config|
         
     | 
| 
       241 
241 
     | 
    
         
             
              config.redis.configure do |redis_config|
         
     | 
| 
       242 
242 
     | 
    
         
             
                redis_config.url = 'redis://user:pass@example.redis.com:90210/'
         
     | 
| 
         @@ -245,12 +245,25 @@ HealthMonitor.configure do |config| 
     | 
|
| 
       245 
245 
     | 
    
         
             
            end
         
     | 
| 
       246 
246 
     | 
    
         
             
            ```
         
     | 
| 
       247 
247 
     | 
    
         | 
| 
      
 248 
     | 
    
         
            +
            Or via a connection pool:
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 251 
     | 
    
         
            +
            # Redis using Connection Pools
         
     | 
| 
      
 252 
     | 
    
         
            +
            HealthMonitor.configure do |config|
         
     | 
| 
      
 253 
     | 
    
         
            +
              config.redis.configure do |redis_config|
         
     | 
| 
      
 254 
     | 
    
         
            +
                redis_config.connection = ConnectionPool.new(size: 5) { Redis.new } # Use your custom connection pool
         
     | 
| 
      
 255 
     | 
    
         
            +
              end
         
     | 
| 
      
 256 
     | 
    
         
            +
            end
         
     | 
| 
      
 257 
     | 
    
         
            +
            ```
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
       248 
259 
     | 
    
         
             
            The currently supported settings are:
         
     | 
| 
       249 
260 
     | 
    
         | 
| 
       250 
261 
     | 
    
         
             
            #### Sidekiq
         
     | 
| 
       251 
262 
     | 
    
         | 
| 
       252 
263 
     | 
    
         
             
            * `latency`: the latency (in seconds) of a queue (now - when the oldest job was enqueued) which is considered unhealthy (the default is 30 seconds, but larger processing queue should have a larger latency value).
         
     | 
| 
       253 
264 
     | 
    
         
             
            * `queue_size`: the size (maximum) of a queue which is considered unhealthy (the default is 100).
         
     | 
| 
      
 265 
     | 
    
         
            +
            * `default_queue`: the default queue to check.
         
     | 
| 
      
 266 
     | 
    
         
            +
            * `add_queue_configuration`: add specific configuration per queue.
         
     | 
| 
       254 
267 
     | 
    
         | 
| 
       255 
268 
     | 
    
         
             
            #### Redis
         
     | 
| 
       256 
269 
     | 
    
         | 
| 
         @@ -8,8 +8,15 @@ module HealthMonitor 
     | 
|
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                class Database < Base
         
     | 
| 
       10 
10 
     | 
    
         
             
                  def check!
         
     | 
| 
       11 
     | 
    
         
            -
                     
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
                    failed_databases = []
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                    ActiveRecord::Base.connection_handler.all_connection_pools.each do |cp|
         
     | 
| 
      
 14 
     | 
    
         
            +
                      cp.connection.check_version
         
     | 
| 
      
 15 
     | 
    
         
            +
                    rescue Exception
         
     | 
| 
      
 16 
     | 
    
         
            +
                      failed_databases << cp.db_config.name
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    raise "unable to connect to: #{failed_databases.uniq.join(',')}" unless failed_databases.empty?
         
     | 
| 
       13 
20 
     | 
    
         
             
                  rescue Exception => e
         
     | 
| 
       14 
21 
     | 
    
         
             
                    raise DatabaseException.new(e.message)
         
     | 
| 
       15 
22 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -12,6 +12,7 @@ module HealthMonitor 
     | 
|
| 
       12 
12 
     | 
    
         
             
                    DEFAULT_QUEUE_NAME = 'default'
         
     | 
| 
       13 
13 
     | 
    
         
             
                    DEFAULT_LATENCY_TIMEOUT = 30
         
     | 
| 
       14 
14 
     | 
    
         
             
                    DEFAULT_QUEUES_SIZE = 100
         
     | 
| 
      
 15 
     | 
    
         
            +
                    DEFAULT_RETRY_CHECK = 20
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
       16 
17 
     | 
    
         
             
                    attr_reader :queues
         
     | 
| 
       17 
18 
     | 
    
         | 
| 
         @@ -53,6 +54,7 @@ module HealthMonitor 
     | 
|
| 
       53 
54 
     | 
    
         
             
                    check_latency!
         
     | 
| 
       54 
55 
     | 
    
         
             
                    check_queue_size!
         
     | 
| 
       55 
56 
     | 
    
         
             
                    check_redis!
         
     | 
| 
      
 57 
     | 
    
         
            +
                    check_amount_of_retries!
         
     | 
| 
       56 
58 
     | 
    
         
             
                  rescue Exception => e
         
     | 
| 
       57 
59 
     | 
    
         
             
                    raise SidekiqException.new(e)
         
     | 
| 
       58 
60 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -95,6 +97,13 @@ module HealthMonitor 
     | 
|
| 
       95 
97 
     | 
    
         
             
                    end
         
     | 
| 
       96 
98 
     | 
    
         
             
                  end
         
     | 
| 
       97 
99 
     | 
    
         | 
| 
      
 100 
     | 
    
         
            +
                  def check_amount_of_retries!
         
     | 
| 
      
 101 
     | 
    
         
            +
                    maximum_amount_of_retries = ::HealthMonitor::Providers::Sidekiq::Configuration::DEFAULT_RETRY_CHECK
         
     | 
| 
      
 102 
     | 
    
         
            +
                    jobs_over_limit = ::Sidekiq::RetrySet.new.select { |job| job.item['retry_count'] >= maximum_amount_of_retries }
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                    raise "amount of retries for a job is greater than #{maximum_amount_of_retries}" if jobs_over_limit.any?
         
     | 
| 
      
 105 
     | 
    
         
            +
                  end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
       98 
107 
     | 
    
         
             
                  def check_redis!
         
     | 
| 
       99 
108 
     | 
    
         
             
                    if ::Sidekiq.respond_to?(:redis_info)
         
     | 
| 
       100 
109 
     | 
    
         
             
                      ::Sidekiq.redis_info
         
     | 
    
        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:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 10.1.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:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-01-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: railties
         
     | 
| 
         @@ -16,14 +16,14 @@ dependencies: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - ">="
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '6.1'
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
24 
     | 
    
         
             
                - - ">="
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '6.1'
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
28 
     | 
    
         
             
              name: appraisal
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     |