heartcheck 1.4.0 → 1.5.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
- SHA1:
3
- metadata.gz: 45a358d7f3a8864deb797ecb5639d0e4df274c66
4
- data.tar.gz: 530d7ecd987f302e38b41395abe67bc9a4ffced3
2
+ SHA256:
3
+ metadata.gz: 6dfd09304fc0ad36774293f2e0e04a3d3ea542acf6ac86bb4415fb558815f109
4
+ data.tar.gz: d6ef9bcee013849cf771c2e14c3699bc53bd664fc5be70a091dc63c5d54c63fd
5
5
  SHA512:
6
- metadata.gz: 55db326b56112e68f33b488d27bab4dd1d0442aae29f88a2c8f3dfe28e96fdfaadd0dd9e4b01dbaf9f915495cf7fcbe6b7133af1d73c4b662344d9507f1e1c71
7
- data.tar.gz: 2d54d671c2944e925d935e7cc3bd6f7db53c0c1d3f2d10b4bc013dd03fbcc100ad60de6b8789a136449ebc4b1a032ca36e5af5718cce2bfd84b49d67f1dd7a46
6
+ metadata.gz: 63907f0c4b890db4b3466160bb2fe2707058f3fd3f25ef3e33380fca89f04fa9c0a16d74f929fadc686641b2ce43016021272f9436e40635aed83369d3ad56ca
7
+ data.tar.gz: f56971cdc1ad9d83dc1a0dbc62ca3da7de40bb536f0fd79116346c5055b5c1dc8491fc6857046ab83fce439131c154ba6941084ddcd88e378ecdb0ca26fdcef1
data/CHANGELOG CHANGED
@@ -1,5 +1,9 @@
1
1
  = Heart Check - Changelog
2
2
 
3
+ == Version 1.5.0 :: 2018-11-29
4
+
5
+ * Adds the '/monitoring/inspect' endpoint to get general info and dependencies
6
+
3
7
  == Version 1.4.0 :: 2017-12-27
4
8
 
5
9
  * Adds property `doc_url` to Checks::Base to provide more details about the
data/README.md CHANGED
@@ -37,6 +37,26 @@ Then edit the generated file by adding your checks on it and restart your
37
37
  server. Now you should be able to make a HTTP request for `/monitoring` and
38
38
  get a JSON response that contains the status for each monitored service.
39
39
 
40
+ The following environment variables are needed by heartcheck:
41
+
42
+ HEARTCHECK_APP_NAME=MyApplicationName
43
+
44
+
45
+ ### Using built-in checks
46
+
47
+ #### Firewall check
48
+
49
+ ```ruby
50
+ Heartcheck.setup do |config|
51
+ config.add :firewall do |c|
52
+ c.add_service(host: 'domain.com', port: 80)
53
+ c.add_service(host: 'domain.com', port: 80, timeout: 5) # Default timeout is 2 seconds
54
+ c.add_service(url: 'https://domain.com')
55
+ c.add_service(url: 'https://domain.com', proxy: 'http://proxy.domain.com')
56
+ end
57
+ end
58
+ ```
59
+
40
60
  ## HTTP Routes
41
61
 
42
62
  #### Basic health check
@@ -74,6 +94,13 @@ checks:
74
94
 
75
95
  /monitoring/health_check
76
96
 
97
+
98
+ #### General info and dependencies
99
+
100
+ Returns general application info and a list of dependencies' URIs, but executes no checking:
101
+
102
+ /monitoring/inspect
103
+
77
104
  ## Plugins
78
105
 
79
106
  * [ActiveRecord](https://github.com/locaweb/heartcheck-activerecord)
@@ -16,6 +16,7 @@ module Heartcheck
16
16
  '/functional' => Controllers::Functional,
17
17
  '/dev' => Controllers::Dev,
18
18
  '/info' => Controllers::Info,
19
+ '/inspect' => Controllers::Inspect,
19
20
  '/health_check' => Controllers::HealthCheck,
20
21
  '/environment' => Controllers::Environment
21
22
  }
@@ -133,6 +133,13 @@ module Heartcheck
133
133
  "#<#{self.class.name} name: #{name}, functional: #{functional?}, dev: #{dev?}>"
134
134
  end
135
135
 
136
+ # Returns a structure comprised of host, port and
137
+ # schema (protocol) for the check
138
+ #
139
+ # @return [Hash]
140
+ def uri_info
141
+ { error: "#{self.class.name} #url_info not implemented." }
142
+ end
136
143
 
137
144
  def informations
138
145
  info
@@ -16,6 +16,16 @@ module Heartcheck
16
16
  end
17
17
  end
18
18
 
19
+ def uri_info
20
+ services.map do |s|
21
+ {
22
+ host: s.uri.host,
23
+ port: s.uri.port,
24
+ scheme: s.uri.scheme
25
+ }
26
+ end
27
+ end
28
+
19
29
  private
20
30
 
21
31
  def custom_error(service)
@@ -0,0 +1,25 @@
1
+ module Heartcheck
2
+ module Controllers
3
+ class Inspect < Base
4
+ def index
5
+ results = {
6
+ application_name: application_name,
7
+ dependencies: []
8
+ }
9
+
10
+ checks = Heartcheck.checks
11
+ results[:dependencies] += checks.reduce([]) do |acc, elem|
12
+ acc << elem.uri_info
13
+ end.flatten.uniq
14
+
15
+ MultiJson.dump(results)
16
+ end
17
+
18
+ private
19
+
20
+ def application_name
21
+ ENV.fetch('HEARTCHECK_APP_NAME')
22
+ end
23
+ end
24
+ end
25
+ end
@@ -14,13 +14,13 @@ module Heartcheck
14
14
  # @option params [Integer] :port Number of port to check
15
15
  # @option params [String] :proxy The uri of your proxy if is required
16
16
  # @option params [integer] :timeout (defaults to: 2) Number in seconds
17
- # @option params [string] :uri You can pass a URI instead a host and port
17
+ # @option params [string] :url You can pass a URI instead a host and port
18
18
  #
19
19
  # @example
20
20
  # Firewall.new(host: 'domain.com', port: 80)
21
21
  # Firewall.new(host: 'domain.com', port: 80, timeout: 5)
22
- # Firewall.new(uri: 'https://domain.com')
23
- # Firewall.new(uri: 'https://domain.com', proxy: 'http://proxy.domain.com')
22
+ # Firewall.new(url: 'https://domain.com')
23
+ # Firewall.new(url: 'https://domain.com', proxy: 'http://proxy.domain.com')
24
24
  #
25
25
  # @return [void]
26
26
  def initialize(params)
@@ -1,3 +1,3 @@
1
1
  module Heartcheck
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heartcheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Locaweb
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-28 00:00:00.000000000 Z
11
+ date: 2018-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -243,6 +243,7 @@ files:
243
243
  - lib/heartcheck/controllers/functional.rb
244
244
  - lib/heartcheck/controllers/health_check.rb
245
245
  - lib/heartcheck/controllers/info.rb
246
+ - lib/heartcheck/controllers/inspect.rb
246
247
  - lib/heartcheck/errors.rb
247
248
  - lib/heartcheck/errors/routing_error.rb
248
249
  - lib/heartcheck/errors/warning.rb
@@ -276,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
277
  version: '0'
277
278
  requirements: []
278
279
  rubyforge_project:
279
- rubygems_version: 2.6.13
280
+ rubygems_version: 2.7.7
280
281
  signing_key:
281
282
  specification_version: 4
282
283
  summary: A simple way to check if your app is runnig like as expected.