kubernetes-health 3.3.1 → 3.4.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
2
  SHA256:
3
- metadata.gz: 59bbdf0e963539df25aa7a994a4fcc54a653506d76df2fa5aa6bbae70994ee98
4
- data.tar.gz: b783c8b8df00a8304b5f853b0c13ce9fe09bf8972b55c906d15f42a23c23c5b0
3
+ metadata.gz: b50f5907432e2efafb49e0541ff792e1bfb086e0b5ced6f2c21308a20cf5e1e0
4
+ data.tar.gz: 2ca4a7a600c71caf1704272c95bbb7d2c354d0bdd32e1eee778f10b39043ea90
5
5
  SHA512:
6
- metadata.gz: 103a26a9a2224f13e246fe1dcc2544990f39a1944f2c989626e0cf44a903a84b2a2fc88b293e1a6ce4269498ccf9abd988a55c4a2ebe7282cbd209371bebd5a2
7
- data.tar.gz: 3cd7707bd895b10acb41c68f9d574320599fe5ac1e01fb29f30e9afe2c2a26b382443e2f1db9f0ef4b9dabe54a8641f32920b38075a8151e0405a67ed815e310
6
+ metadata.gz: d633dc94b6e18c839cdb0658efc6fbcb3d924b73dc8fb23a14bdb4b6babcdd856d5ee6f0eccd2cd4bae24272b97678d5fab4fee4154493c1a11a196a37532a57
7
+ data.tar.gz: c49e6472031a756436d3f17d6c3b1f2a736c3dcbdd1c63c13c0f980e200eff31d217bb44d48f8901eaecc90d75daef74c9a2261c0816e245977afa2755dd4c64
data/README.md CHANGED
@@ -15,7 +15,7 @@ This gem allows kubernetes monitoring your app while it is running migrates and
15
15
  Add this line to your application's Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'kubernetes-health', '~> 3.3'
18
+ gem 'kubernetes-health', '~> 3.4'
19
19
  ```
20
20
 
21
21
  ## Enabling puma plugin
@@ -1,5 +1,5 @@
1
1
  module Kubernetes
2
2
  module Health
3
- VERSION = "3.3.1"
3
+ VERSION = "3.4.0"
4
4
  end
5
5
  end
@@ -27,8 +27,12 @@ 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
- @parser.parse JSON.parse(@launcher.stats)
31
- content = ::Kubernetes::Health::Config.response_format == 'json' ? @launcher.stats : Prometheus::Client::Formats::Text.marshal(Prometheus::Client.registry)
30
+ if ::Kubernetes::Health::Config.response_format == 'json'
31
+ content = include_puma_key_prefix(include_usage(JSON.parse(@launcher.stats))).to_json
32
+ else
33
+ @parser.parse include_usage(JSON.parse(@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
@@ -39,6 +43,18 @@ module Puma
39
43
  ::Kubernetes::Health::Config.request_log_callback.call(req, http_code, content)
40
44
  [http_code, type, [content]]
41
45
  end
46
+
47
+ def include_usage(stats)
48
+ stats['usage'] = (1 - stats['pool_capacity'].to_f / stats['max_threads']).round(2)
49
+ stats
50
+ end
51
+ def include_puma_key_prefix(stats)
52
+ result = {}
53
+ stats.each do |k,v|
54
+ result["puma_#{k}"] = v
55
+ end
56
+ result
57
+ end
42
58
  end
43
59
  end
44
60
  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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubernetes-health
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wagner Caixeta