kubernetes-health 3.3.0 → 3.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/kubernetes-health.gemspec +1 -1
- data/lib/kubernetes/health/version.rb +1 -1
- data/lib/puma/kubernetes/app.rb +30 -5
- data/lib/puma/kubernetes/parser.rb +1 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d7d7ca3715c624f28575a1af905a79df3b2c3ce4b6d7370ecca88450a98e58e
|
4
|
+
data.tar.gz: ec8c4cb288f68ac86904f15135308a49b801b814b14313ddb5d611e02243600e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b73ef9ee17ab78d1ec044a75ac71787fedb9d86e292bcccbf21a3ae55693db7b65cc4634204596ae815500f8cb040cf72e026352faaeed7b2e3e5251c09fc084
|
7
|
+
data.tar.gz: 3663742f867ab3a01c97eb5c8ed93f6a2904f3e7d68540e1a3caf478f0c585e64d289e6a8523a4b64e2becd67a35da6d34b9d921808c3e14deb9289798ea6845
|
data/README.md
CHANGED
data/kubernetes-health.gemspec
CHANGED
@@ -31,6 +31,6 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency "rspec"
|
32
32
|
spec.add_dependency "rack"
|
33
33
|
spec.add_dependency "rails"
|
34
|
-
spec.add_runtime_dependency 'prometheus-client'
|
34
|
+
spec.add_runtime_dependency 'prometheus-client', '~> 0.9.0'
|
35
35
|
spec.add_runtime_dependency 'puma'
|
36
36
|
end
|
data/lib/puma/kubernetes/app.rb
CHANGED
@@ -16,7 +16,7 @@ module Puma
|
|
16
16
|
begin
|
17
17
|
req = ::Rack::Request.new(_env)
|
18
18
|
type = {}
|
19
|
-
content =
|
19
|
+
content = ''
|
20
20
|
type = ::Kubernetes::Health::Config.response_format == 'json' ? { 'Content-Type' => 'application/json' } : { 'Content-Type' => 'text/plain' }
|
21
21
|
case req.path_info
|
22
22
|
when ::Kubernetes::Health::Config.route_liveness
|
@@ -27,18 +27,43 @@ module Puma
|
|
27
27
|
http_code = i_am_ready ? 200 : 503
|
28
28
|
when ::Kubernetes::Health::Config.route_metrics
|
29
29
|
http_code = 200
|
30
|
-
|
31
|
-
|
30
|
+
if ::Kubernetes::Health::Config.response_format == 'json'
|
31
|
+
content = include_puma_key_prefix(include_usage(@launcher.stats)).to_json
|
32
|
+
else
|
33
|
+
@parser.parse include_usage(@launcher.stats)
|
34
|
+
content = Prometheus::Client::Formats::Text.marshal(Prometheus::Client.registry)
|
35
|
+
end
|
32
36
|
else
|
33
37
|
http_code = 404
|
34
38
|
end
|
35
|
-
rescue
|
39
|
+
rescue => e
|
40
|
+
Rails.logger.error e.message
|
41
|
+
Rails.logger.error e.backtrace.join("\n")
|
36
42
|
http_code = 500
|
37
|
-
content =
|
43
|
+
content = ''
|
38
44
|
end
|
39
45
|
::Kubernetes::Health::Config.request_log_callback.call(req, http_code, content)
|
40
46
|
[http_code, type, [content]]
|
41
47
|
end
|
48
|
+
|
49
|
+
def include_usage(stats)
|
50
|
+
if stats.is_a?(String)
|
51
|
+
# puma <= 4.
|
52
|
+
stats = JSON.parse(stats)
|
53
|
+
else
|
54
|
+
# Puma >=5 uses symbol.
|
55
|
+
stats = JSON.parse(stats.to_json)
|
56
|
+
end
|
57
|
+
stats['usage'] = (1 - stats['pool_capacity'].to_f / stats['max_threads']).round(2)
|
58
|
+
stats
|
59
|
+
end
|
60
|
+
def include_puma_key_prefix(stats)
|
61
|
+
result = {}
|
62
|
+
stats.each do |k,v|
|
63
|
+
result["puma_#{k}"] = v
|
64
|
+
end
|
65
|
+
result
|
66
|
+
end
|
42
67
|
end
|
43
68
|
end
|
44
69
|
end
|
@@ -29,6 +29,7 @@ module Puma
|
|
29
29
|
registry.gauge(:puma_pool_capacity, 'Number of allocatable worker threads', index: 0)
|
30
30
|
registry.gauge(:puma_max_threads, 'Maximum number of worker threads', index: 0)
|
31
31
|
registry.gauge(:puma_workers, 'Number of configured workers').set({}, 1)
|
32
|
+
registry.gauge(:puma_usage, 'Result of (1 - puma_pool_capacity/puma_max_threads)', index: 0)
|
32
33
|
end
|
33
34
|
|
34
35
|
def registry
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubernetes-health
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wagner Caixeta
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: prometheus-client
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.9.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 0.9.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: puma
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
- !ruby/object:Gem::Version
|
161
161
|
version: '0'
|
162
162
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
163
|
+
rubygems_version: 3.1.4
|
164
164
|
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: This gem allows kubernetes monitoring your app while it is running migrates
|