kubernetes-health 3.8.0 → 3.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/config/initializers/enable_rack_on_sidekiq.rb +1 -1
- data/kubernetes-health.gemspec +1 -1
- data/lib/kubernetes/health/config.rb +4 -4
- data/lib/kubernetes/health/rack_on_sidekiq.rb +15 -12
- data/lib/kubernetes/health/sidekiq_options_resolver.rb +12 -0
- data/lib/kubernetes/health/version.rb +1 -1
- data/lib/kubernetes/health.rb +1 -0
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5153394dce8ea22cce62b0826008d9febbeb406b6385296471cb00b6e6c50c52
|
4
|
+
data.tar.gz: ae76165497abc6c256d4609c28f27b782fc7d69f88a93a511c94567395c2716c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81ce8eaa10395f924d68cca575114a8e47c65f3c3c710b9a66f1801834518556dfa401f5c365586dd13a868758afdb2c83cfbd127034026cf0bf3b83eecde7ce
|
7
|
+
data.tar.gz: e2d8ce82aeb1fe27b7e0a76db760f24dcbf297fbb41bcbc0a4b66354bf04cb4a3e830b8409f6a9fdbd17e88fc79e1627e4b8cb06315619f84fbd2d74e53a0f89
|
data/README.md
CHANGED
@@ -131,6 +131,12 @@ Kubernetes::Health::Config.route_liveness = '/liveness'
|
|
131
131
|
Kubernetes::Health::Config.route_readiness = '/readiness'
|
132
132
|
Kubernetes::Health::Config.route_metrics = '/metrics'
|
133
133
|
```
|
134
|
+
or using env
|
135
|
+
```
|
136
|
+
KUBERNETES_HEALTH_LIVENESS_ROUTE='/liveness'
|
137
|
+
KUBERNETES_HEALTH_READINESS_ROUTE='/readiness'
|
138
|
+
KUBERNETES_HEALTH_RESPONSE_FORMAT='/metrics'
|
139
|
+
```
|
134
140
|
|
135
141
|
## Response format
|
136
142
|
If you are using `https://github.com/zalando-incubator/kube-metrics-adapter` you will want to use `json` format.
|
@@ -139,6 +145,10 @@ Default is `prometheus`.
|
|
139
145
|
```
|
140
146
|
Kubernetes::Health::Config.response_format = 'json'
|
141
147
|
```
|
148
|
+
or using env
|
149
|
+
```
|
150
|
+
KUBERNETES_HEALTH_RESPONSE_FORMAT=json
|
151
|
+
```
|
142
152
|
|
143
153
|
## Customizing requests logs
|
144
154
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'kubernetes/health/rack_on_sidekiq'
|
2
2
|
|
3
|
-
if Kubernetes::Health::Config.enable_rack_on_sidekiq &&
|
3
|
+
if Kubernetes::Health::Config.enable_rack_on_sidekiq && Kubernetes::Health::SidekiqOptionsResolver[:concurrency].positive?
|
4
4
|
Thread.new do
|
5
5
|
Rack::Handler.default.run Kubernetes::Health::RackOnSidekiq.new
|
6
6
|
end
|
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', '>= 1.0', '< 5'
|
35
35
|
spec.add_runtime_dependency 'puma', '>= 5.0'
|
36
36
|
end
|
@@ -6,10 +6,10 @@ module Kubernetes
|
|
6
6
|
@@enable_lock_on_migrate = [true, 'true'].include? ENV['KUBERNETES_HEALTH_ENABLE_LOCK_ON_MIGRATE']
|
7
7
|
@@enable_rack_on_migrate = [true, 'true'].include? ENV['KUBERNETES_HEALTH_ENABLE_RACK_ON_MIGRATE']
|
8
8
|
@@enable_rack_on_sidekiq = [true, 'true'].include? ENV['KUBERNETES_HEALTH_ENABLE_RACK_ON_SIDEKIQ']
|
9
|
-
@@route_liveness = '/_liveness'
|
10
|
-
@@route_readiness = '/_readiness'
|
11
|
-
@@route_metrics = '/_metrics'
|
12
|
-
@@response_format = 'prometheus'
|
9
|
+
@@route_liveness = ENV['KUBERNETES_HEALTH_LIVENESS_ROUTE'] || '/_liveness'
|
10
|
+
@@route_readiness = ENV['KUBERNETES_HEALTH_READINESS_ROUTE'] || '/_readiness'
|
11
|
+
@@route_metrics = ENV['KUBERNETES_HEALTH_METRICS_ROUTE'] || '/_metrics'
|
12
|
+
@@response_format = ENV['KUBERNETES_HEALTH_RESPONSE_FORMAT'] || 'prometheus'
|
13
13
|
|
14
14
|
@@request_log_callback = lambda { |req, http_code, content|
|
15
15
|
Rails.logger.debug "Kubernetes Health - Request: Path: #{req.path_info} / Params: #{req.params} / HTTP Code: #{http_code}\n#{content}" rescue nil
|
@@ -5,6 +5,7 @@ require 'prometheus/client/formats/text'
|
|
5
5
|
module Kubernetes
|
6
6
|
module Health
|
7
7
|
class RackOnSidekiq
|
8
|
+
|
8
9
|
def call(env)
|
9
10
|
req = ::Rack::Request.new(env)
|
10
11
|
content = ''
|
@@ -18,10 +19,9 @@ module Kubernetes
|
|
18
19
|
if ::Kubernetes::Health::Config.response_format == 'json'
|
19
20
|
content = sidekiq_metrics.to_json
|
20
21
|
else
|
21
|
-
prometheus_registry
|
22
|
-
prometheus_registry.get(:
|
23
|
-
prometheus_registry.get(:
|
24
|
-
prometheus_registry.get(:sidekiq_usage).set({}, sidekiq_metrics[:sidekiq_usage])
|
22
|
+
prometheus_registry.get(:sidekiq_capacity).set(sidekiq_metrics[:sidekiq_capacity])
|
23
|
+
prometheus_registry.get(:sidekiq_busy).set(sidekiq_metrics[:sidekiq_busy])
|
24
|
+
prometheus_registry.get(:sidekiq_usage).set(sidekiq_metrics[:sidekiq_usage])
|
25
25
|
content = Prometheus::Client::Formats::Text.marshal(prometheus_registry)
|
26
26
|
end
|
27
27
|
else
|
@@ -32,25 +32,28 @@ module Kubernetes
|
|
32
32
|
[http_code, type, [content]]
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
prometheus_registry
|
37
|
-
|
38
|
-
prometheus_registry
|
39
|
-
prometheus_registry.gauge(:
|
40
|
-
prometheus_registry
|
35
|
+
def prometheus_registry
|
36
|
+
return @prometheus_registry unless @prometheus_registry.nil?
|
37
|
+
|
38
|
+
@prometheus_registry = Prometheus::Client.registry
|
39
|
+
@prometheus_registry.gauge(:sidekiq_capacity, docstring: 'Sidekiq Threads Number')
|
40
|
+
@prometheus_registry.gauge(:sidekiq_busy, docstring: 'Sidekiq Busy Threads')
|
41
|
+
@prometheus_registry.gauge(:sidekiq_usage, docstring: 'Result of sidekiq_busy/sidekiq_capacity')
|
42
|
+
@prometheus_registry
|
41
43
|
end
|
42
44
|
|
43
45
|
def generate_sidekiq_metrics
|
44
|
-
sidekiq_info = Sidekiq::ProcessSet.new.to_a.filter { |p| p.identity ==
|
46
|
+
sidekiq_info = Sidekiq::ProcessSet.new.to_a.filter { |p| p.identity == SidekiqOptionsResolver[:identity] }
|
45
47
|
|
46
48
|
stats = {
|
47
|
-
sidekiq_capacity:
|
49
|
+
sidekiq_capacity: SidekiqOptionsResolver[:concurrency],
|
48
50
|
sidekiq_busy: sidekiq_info.size.zero? ? 0 : sidekiq_info[0]['busy']
|
49
51
|
}
|
50
52
|
|
51
53
|
stats[:sidekiq_usage] = (stats[:sidekiq_busy] / stats[:sidekiq_capacity].to_f).round(2)
|
52
54
|
stats
|
53
55
|
end
|
56
|
+
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|
data/lib/kubernetes/health.rb
CHANGED
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.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wagner Caixeta
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,16 +84,22 @@ 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
89
|
version: '1.0'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '5'
|
90
93
|
type: :runtime
|
91
94
|
prerelease: false
|
92
95
|
version_requirements: !ruby/object:Gem::Requirement
|
93
96
|
requirements:
|
94
|
-
- - "
|
97
|
+
- - ">="
|
95
98
|
- !ruby/object:Gem::Version
|
96
99
|
version: '1.0'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '5'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: puma
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +145,7 @@ files:
|
|
139
145
|
- lib/kubernetes/health/rack_on_migrate.rb
|
140
146
|
- lib/kubernetes/health/rack_on_sidekiq.rb
|
141
147
|
- lib/kubernetes/health/railtie.rb
|
148
|
+
- lib/kubernetes/health/sidekiq_options_resolver.rb
|
142
149
|
- lib/kubernetes/health/version.rb
|
143
150
|
- lib/puma/kubernetes/app.rb
|
144
151
|
- lib/puma/kubernetes/dsl.rb
|