okcomputer 1.18.5 → 1.19.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: 6b0d00a1c27b81d74873969d466755cbb53f39891dd1d83f18e9912f155daaec
4
- data.tar.gz: e2f26b7017a2948403a728e9714b9e732ab1f07a7393b40ed70382d1d034c15f
3
+ metadata.gz: 834e3e304e55f2824d48769656b7fbfda10219d176d23fc445adfeaef01aaca8
4
+ data.tar.gz: 958d4a30a4a391f31734713f56dea8b492b7952b53bb7f339aa168a8e37d133f
5
5
  SHA512:
6
- metadata.gz: f3f509cdc9465236d912549083636aa2dc58bd16bd80fdb167533c3cbd7f17fd3e9405b59db84e480cb3122a00e948ac6b8d61d43c5ca695aeb61ab732cc4cf0
7
- data.tar.gz: 9d0df64eb500c33bd45c2192006798bc909941fe43bedfb639966006d0cf763ab558e23b1086a131b0fe3945ced41922764f46b976da3ea7c3d5eea264779ed5
6
+ metadata.gz: 64d45f7f723099e15f7fc54e305029c6893a16e81fdd1ac353343d0be1b8f3ee7a33c412591dd343c6ddc84c9495ae85bb79ad742804019ba0e627e8dffddae0
7
+ data.tar.gz: 92429b914eff4069011dfd05aeba9b4ab725816b1f43ceb0b16b1f4e6c12894776d0e0475afe2f75fdf29539d1b7d9047d37a9c42708f6b5bf385a9f6d2c0029
data/MIT-LICENSE CHANGED
@@ -1,4 +1,5 @@
1
- Copyright 2017 SportsEngine
1
+ Copyright 2024 Emma Sax
2
+ Copyright 2017-2024 SportsEngine
2
3
 
3
4
  Permission is hereby granted, free of charge, to any person obtaining
4
5
  a copy of this software and associated documentation files (the
data/README.markdown CHANGED
@@ -1,20 +1,21 @@
1
- [![Code Climate](https://codeclimate.com/github/sportngin/okcomputer.svg)](https://codeclimate.com/github/sportngin/okcomputer)
2
- [![Build Status](https://github.com/sportngin/okcomputer/workflows/CI/badge.svg)](https://github.com/sportngin/okcomputer/actions?query=workflow%3ACI)
1
+ [![Gem Version](https://badge.fury.io/rb/okcomputer.svg)](https://badge.fury.io/rb/okcomputer)
2
+ [![Downloads](https://img.shields.io/gem/dt/okcomputer.svg)](https://rubygems.org/gems/okcomputer)
3
+ [![License](https://img.shields.io/github/license/emmahsax/okcomputer.svg)](LICENSE)
4
+ [![Ruby Versions](https://img.shields.io/badge/Ruby-%3E%3D%202.1-brightgreen.svg)](https://www.ruby-lang.org)
5
+ [![Build Status](https://github.com/emmahsax/okcomputer/actions/workflows/ci.yml/badge.svg)](https://github.com/emmahsax/okcomputer/actions/workflows/ci.yml)
3
6
 
4
- # OK Computer
7
+ # OkComputer
5
8
 
6
- Inspired by the ease of installing and setting up [fitter-happier] as a Rails
9
+ Inspired by the ease of installing and setting up [fitter-happier](https://rubygems.org/gems/fitter-happier) as a Rails
7
10
  application's health check, but frustrated by its lack of flexibility, OK
8
11
  Computer was born. It provides a robust endpoint to perform server health
9
12
  checks with a set of built-in plugins, as well as a simple interface to add
10
13
  your own custom checks.
11
14
 
12
15
  For more insight into why we built this, check out [our blog post introducing
13
- OK Computer][blog].
16
+ OkComputer](http://pulse.sportngin.com/news_article/show/267646?referrer_id=543230).
14
17
 
15
- [blog]:http://pulse.sportngin.com/news_article/show/267646?referrer_id=543230
16
-
17
- OkComputer currently supports the following Rails versions:
18
+ OkComputer currently fully supports the following Rails versions:
18
19
 
19
20
  * 7.0
20
21
  * 6.1
@@ -23,26 +24,38 @@ OkComputer currently supports the following Rails versions:
23
24
  * 5.1
24
25
  * 4.2
25
26
 
26
- #### Not using Rails?
27
+ In addition, the CI tests are passing on, but is not guaranteed to work with, the following Rails versions:
27
28
 
28
- If you use [Grape] instead of Rails, check out [okcomputer-grape].
29
+ * 8.0
30
+ * 7.2
31
+ * 7.1
32
+ * 5.0
33
+ * 4.1
34
+ * 4.0
29
35
 
30
- [Grape]:https://github.com/ruby-grape/grape
31
- [okcomputer-grape]:https://github.com/bellycard/okcomputer-grape
36
+ #### Not using Rails?
37
+
38
+ If you use [Grape](https://github.com/ruby-grape/grape) instead of Rails, check out [okcomputer-grape](https://github.com/bellycard/okcomputer-grape).
32
39
 
33
40
  ## Installation
34
41
 
35
42
  Add this line to your application's Gemfile:
36
43
 
37
- gem 'okcomputer'
44
+ ```ruby
45
+ gem 'okcomputer'
46
+ ```
38
47
 
39
48
  And then execute:
40
49
 
41
- $ bundle
50
+ ```
51
+ $ bundle
52
+ ```
42
53
 
43
54
  Or install it yourself as:
44
55
 
45
- $ gem install okcomputer
56
+ ```
57
+ $ gem install okcomputer
58
+ ```
46
59
 
47
60
  ## Usage
48
61
 
@@ -86,7 +99,7 @@ you can configure it with:
86
99
 
87
100
  ```ruby
88
101
  # config/initializers/okcomputer.rb
89
- OkComputer.mount_at = 'health_checks' # mounts at /health_checks
102
+ OkComputer.mount_at = 'health_checks' # Mounts at /health_checks
90
103
  ```
91
104
 
92
105
  For more control of adding OkComputer to your routes, set `OkComputer.mount_at
@@ -109,7 +122,7 @@ Log check results by setting `OkComputer.logger`. Note: results will be logged a
109
122
  OkComputer.logger = Rails.logger
110
123
  ```
111
124
 
112
- ```sh
125
+ ```
113
126
  [okcomputer] mycheck: PASSED mymessage (0s)
114
127
  ```
115
128
 
@@ -124,6 +137,9 @@ OkComputer::Registry.register "resque_backed_up", OkComputer::ResqueBackedUpChec
124
137
 
125
138
  # This check works on 2.4.0 and above versions of resque-scheduler
126
139
  OkComputer::Registry.register "resque_scheduler_down", OkComputer::ResqueSchedulerCheck.new
140
+
141
+ # If you're using SolidCache instead of Memcached, use this check instead of CacheCheck
142
+ OkComputer::Registry.register "cache", OkComputer::CacheCheckSolidCache.new
127
143
  ```
128
144
 
129
145
  ### Registering Custom Checks
@@ -168,9 +184,7 @@ This check will run and report its status, but will not affect the HTTP status c
168
184
  The plain-text output flows through Rails' internationalization framework.
169
185
  Adjust the output as necessary by defining `okcomputer.check.passed` and
170
186
  `okcomputer.check.failed` keys in your setup. The default values are available
171
- [in `okcomputer.en.yml`][i18n].
172
-
173
- [i18n]:https://github.com/sportngin/okcomputer/blob/eb0be05cc1527e083edd63cfbb0a071f7892c822/config/locales/okcomputer.en.yml#L1-L5
187
+ [in `okcomputer.en.yml`](https://github.com/emmahsax/okcomputer/blob/main/config/locales/okcomputer.en.yml).
174
188
 
175
189
  ## Running checks in parallel
176
190
 
@@ -198,7 +212,7 @@ as it will start to artificially bring your request time down.
198
212
 
199
213
  If you'd like to intentionally count OkComputer requests in your NewRelic analytics, set:
200
214
 
201
- ```
215
+ ```ruby
202
216
  # config/initializers/okcomputer.rb
203
217
  OkComputer.analytics_ignore = false
204
218
  ```
@@ -207,7 +221,7 @@ OkComputer.analytics_ignore = false
207
221
 
208
222
  ### Setup
209
223
 
210
- ```plaintext
224
+ ```
211
225
  $ bundle install
212
226
  ```
213
227
 
@@ -217,7 +231,7 @@ OkComputer tests are written with [RSpec](http://rspec.info/).
217
231
 
218
232
  To run the full test suite:
219
233
 
220
- ```plaintext
234
+ ```
221
235
  $ rake spec
222
236
  ```
223
237
 
@@ -227,10 +241,17 @@ bundle and run the tests with a specific version of Rails.
227
241
 
228
242
  ## Contributing
229
243
 
230
- 1. Fork it
244
+ 1. Fork this repository
231
245
  2. Create your feature branch (`git checkout -b my-new-feature`)
232
246
  3. Commit your changes (`git commit -am 'Add some feature'`)
233
247
  4. Push to the branch (`git push origin my-new-feature`)
234
- 5. Create new Pull Request
248
+ 5. Create a new pull request on upstream (this repository)
249
+ 6. Update [`CHANGELOG.markdown`](https://github.com/emmahsax/okcomputer/blob/main/CHANGELOG.markdown) under an `Unreleased` tag version (create a new one at the top if needed) with summarized changes and link to the pull request
250
+
251
+ ## Releasing
235
252
 
236
- [fitter-happier]:https://rubygems.org/gems/fitter-happier
253
+ 1. Ensure you have push permissions to [RubyGems](https://rubygems.org/gems/okcomputer)
254
+ 2. Merge all PRs so that `main` is up to date with the new version
255
+ 3. Determine the new version ([`lib/ok_computer/version`](https://github.com/emmahsax/okcomputer/blob/main/lib/ok_computer/version.rb) has the current latest one) by following [semantic versioning](https://semver.org/) guidelines
256
+ 4. Ensure you're on the `main` branch and you are locally up to date (`git checkout main && git pull`)
257
+ 5. Run the release script and pass in the new version (`bin/release vX.X.X`... the `v` at the beginning is optional)
data/Rakefile CHANGED
@@ -23,4 +23,3 @@ begin
23
23
  end
24
24
  rescue LoadError
25
25
  end
26
-
@@ -2,36 +2,37 @@ module OkComputer
2
2
  class ActiveRecordMigrationsCheck < Check
3
3
  # Public: Check if migrations are pending or not
4
4
  def check
5
- return unsupported unless supported?
5
+ return mark_message(page_load_message) if check_on_page_load?
6
6
 
7
- if needs_migration?
8
- mark_failure
9
- mark_message "Pending migrations"
10
- else
11
- mark_message "NO pending migrations"
12
- end
13
- end
7
+ error_if_pending_migrations(Rails.version)
14
8
 
15
- def needs_migration?
16
- if ActiveRecord::Migrator.respond_to?(:needs_migration?) # Rails <= 5.1
17
- ActiveRecord::Migrator.needs_migration?
18
- else # Rails >= 5.2
19
- ActiveRecord::Base.connection.migration_context.needs_migration?
20
- end
9
+ mark_message "NO pending migrations"
10
+ rescue ActiveRecord::PendingMigrationError
11
+ mark_failure
12
+ mark_message "Pending migrations"
21
13
  end
22
14
 
23
- def supported?
24
- ActiveRecord::Migrator.respond_to?(:needs_migration?) ||
25
- (ActiveRecord::Base.connection.respond_to?(:migration_context) &&
26
- ActiveRecord::Base.connection.migration_context.respond_to?(:needs_migration?))
15
+ private
16
+
17
+ # this check is only valid if config.active_record.migration_error is set to false rather than :page_load
18
+ # :page_load adds a Middleware check that throws an error before the call reaches ok_computer
19
+ # we only run this check when :page_load is set if there are no pending migrations
20
+ # :page_load is the default in development, otherwise this is false
21
+ # see https://github.com/rails/rails/blob/d39db5d1891f7509cde2efc425c9d69bbb77e670/activerecord/lib/active_record/railtie.rb#L103
22
+ def check_on_page_load?
23
+ Rails.configuration.active_record.migration_error
27
24
  end
28
25
 
29
- private
26
+ def error_if_pending_migrations(version_string)
27
+ if Gem::Version.new(version_string) >= Gem::Version.new("7.1")
28
+ ActiveRecord::Migration.check_all_pending!
29
+ else
30
+ ActiveRecord::Migration.check_pending!
31
+ end
32
+ end
30
33
 
31
- # Private: Fail the check if ActiveRecord cannot check migration status
32
- def unsupported
33
- mark_failure
34
- mark_message "This version of ActiveRecord does not support checking whether migrations are pending"
34
+ def page_load_message
35
+ "NOTE: pending migrations are checked on page_load"
35
36
  end
36
37
  end
37
38
  end
@@ -0,0 +1,49 @@
1
+ module OkComputer
2
+ # Verifies that Rails cache is set up and can speak with SolidCache
3
+ class CacheCheckSolidCache < Check
4
+ # Public: Check whether the cache is active
5
+ def check
6
+ mark_message "Cache is available (#{stats})"
7
+ rescue ConnectionFailed => e
8
+ mark_failure
9
+ mark_message "Error: '#{e}'"
10
+ end
11
+
12
+ # Public: Outputs stats string for cache
13
+ def stats
14
+ return "" unless Rails.cache.respond_to? :stats
15
+
16
+ stats = Rails.cache.stats
17
+ connection_stats = stats[:connection_stats][SolidCache::Entry.current_shard]
18
+
19
+ max_entries = connection_stats[:max_entries]
20
+ current_entries = connection_stats[:entries]
21
+ max_age = connection_stats[:max_age]
22
+ oldest_age = connection_stats[:oldest_age]
23
+
24
+ age_text = if oldest_age
25
+ "oldest: #{format_duration(oldest_age)}, max: #{format_duration(max_age)}"
26
+ else
27
+ "no entries"
28
+ end
29
+
30
+ "entries: #{current_entries}/#{max_entries}, #{age_text}, #{stats[:connections]} connections"
31
+ rescue => e
32
+ raise ConnectionFailed, e
33
+ end
34
+
35
+ private
36
+
37
+ def format_duration(seconds)
38
+ if seconds < 60
39
+ "#{seconds.round}s"
40
+ elsif seconds < 3600
41
+ "#{(seconds / 60).round}m"
42
+ else
43
+ "#{(seconds / 3600).round}h"
44
+ end
45
+ end
46
+
47
+ ConnectionFailed = Class.new(StandardError)
48
+ end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module OkComputer
2
- VERSION = '1.18.5'
2
+ VERSION = '1.19.0'
3
3
  end
data/lib/okcomputer.rb CHANGED
@@ -15,6 +15,7 @@ require "ok_computer/built_in_checks/active_record_check"
15
15
  require "ok_computer/built_in_checks/active_record_migrations_check"
16
16
  require "ok_computer/built_in_checks/app_version_check"
17
17
  require "ok_computer/built_in_checks/cache_check"
18
+ require "ok_computer/built_in_checks/cache_check_solid_cache"
18
19
  require "ok_computer/built_in_checks/default_check"
19
20
  require "ok_computer/built_in_checks/delayed_job_backed_up_check"
20
21
  require "ok_computer/built_in_checks/directory_check"
metadata CHANGED
@@ -1,81 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okcomputer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.5
4
+ version: 1.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Byrne
8
8
  - Andy Fleener
9
9
  - Chris Arcand
10
+ - Emma Sax
11
+ - Ryan McGeary
10
12
  autorequire:
11
13
  bindir: bin
12
14
  cert_chain: []
13
- date: 2023-10-28 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: sqlite3
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "~>"
20
- - !ruby/object:Gem::Version
21
- version: 1.3.6
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - "~>"
27
- - !ruby/object:Gem::Version
28
- version: 1.3.6
29
- - !ruby/object:Gem::Dependency
30
- name: rspec-rails
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - "~>"
34
- - !ruby/object:Gem::Version
35
- version: '4.0'
36
- type: :development
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: '4.0'
43
- - !ruby/object:Gem::Dependency
44
- name: coveralls
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '0'
50
- type: :development
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: '0'
57
- - !ruby/object:Gem::Dependency
58
- name: sequel
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '0'
64
- type: :development
65
- prerelease: false
66
- version_requirements: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: '0'
71
- description: "\n Inspired by the simplicity of Fitter Happier, but frustrated by
72
- its lack of\n flexibility, we built OK Computer. Create and register your own
73
- custom\n health checks, or choose from the built-in library of checks to ensure
74
- your\n app is working as intended.\n "
15
+ date: 2025-02-11 00:00:00.000000000 Z
16
+ dependencies: []
17
+ description: Inspired by the simplicity of Fitter Happier, but frustrated by its lack
18
+ of flexibility, we built OkComputer. Create and register your own custom health
19
+ checks, or choose from the built-in library of checks to ensure your app is working
20
+ as intended.
75
21
  email:
76
22
  - code@patrickbyrne.net
77
23
  - anfleene@gmail.com
78
24
  - chris@chrisarcand.com
25
+ - sax.emma.h@gmail.com
26
+ - ryan@mcgeary.org
79
27
  executables: []
80
28
  extensions: []
81
29
  extra_rdoc_files: []
@@ -91,6 +39,7 @@ files:
91
39
  - lib/ok_computer/built_in_checks/active_record_migrations_check.rb
92
40
  - lib/ok_computer/built_in_checks/app_version_check.rb
93
41
  - lib/ok_computer/built_in_checks/cache_check.rb
42
+ - lib/ok_computer/built_in_checks/cache_check_solid_cache.rb
94
43
  - lib/ok_computer/built_in_checks/default_check.rb
95
44
  - lib/ok_computer/built_in_checks/delayed_job_backed_up_check.rb
96
45
  - lib/ok_computer/built_in_checks/directory_check.rb
@@ -121,10 +70,13 @@ files:
121
70
  - lib/ok_computer/registry.rb
122
71
  - lib/ok_computer/version.rb
123
72
  - lib/okcomputer.rb
124
- homepage: https://github.com/sportngin/okcomputer
73
+ homepage: https://github.com/emmahsax/okcomputer
125
74
  licenses:
126
75
  - MIT
127
- metadata: {}
76
+ metadata:
77
+ bug_tracker_uri: https://github.com/emmahsax/okcomputer/issues
78
+ changelog_uri: https://github.com/emmahsax/okcomputer/blob/main/CHANGELOG.markdown
79
+ source_code_uri: https://github.com/emmahsax/okcomputer
128
80
  post_install_message:
129
81
  rdoc_options: []
130
82
  require_paths:
@@ -133,14 +85,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
85
  requirements:
134
86
  - - ">="
135
87
  - !ruby/object:Gem::Version
136
- version: '0'
88
+ version: '2.1'
137
89
  required_rubygems_version: !ruby/object:Gem::Requirement
138
90
  requirements:
139
91
  - - ">="
140
92
  - !ruby/object:Gem::Version
141
93
  version: '0'
142
94
  requirements: []
143
- rubygems_version: 3.2.33
95
+ rubygems_version: 3.5.22
144
96
  signing_key:
145
97
  specification_version: 4
146
98
  summary: A simple, extensible health-check monitor