yabeda-gruf 1.0.0 → 1.1.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: 825cbd87d9e02b2eb8197d8e50411689d52bcb74817642bc354359759b80a34b
4
- data.tar.gz: 30f0c2b0080898575b86c4d8087371c911765055654c25e3f91769570f8abb12
3
+ metadata.gz: cba67831ad6a67773f2de02c9f927ba569f750ca59437e8544dc46530f523338
4
+ data.tar.gz: 3eca4618f70096714d01ce5a1d1292b24387bdda598f58490a4516e936523ac0
5
5
  SHA512:
6
- metadata.gz: 373830ae75d21f3803ebd457e3394b15f323b737e739f8ffb6b88ec540e1371094d336e60621711f95ae800bcd23e72329ed72ea2900f7786e62cfdc2628779e
7
- data.tar.gz: 7e64ebb48767fc6ed40d8d1e0fa6873cb5d3378a95080d201cdfb1dcf6dce906dbbd514b44ce636ab8b15605261c5c2d13717bb0f2c8354055ffc5be0531d9bf
6
+ metadata.gz: 31e5b10e22305d7d6859b37791241ae32368cf3555c9bedf4ca32d2788e2727eb4b3f2f0a2033f5bb9654378f48056d7a290ddd97cac8d04fb49ec4c1452279a
7
+ data.tar.gz: aa12c743c9da5b0078a5d805ae8df158ebbd70102a0b243d2e33cf4986c1e999b2075e4395f149135b55a5c878a32211b1c29ce5d65986384784c61b80245489
@@ -1,42 +1,43 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yabeda-gruf (1.0.0)
5
- gruf
4
+ yabeda-gruf (1.1.0)
5
+ gruf (>= 2.7.0)
6
6
  yabeda
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (5.2.2)
11
+ activesupport (6.0.3.2)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 0.7, < 2)
14
14
  minitest (~> 5.1)
15
15
  tzinfo (~> 1.1)
16
+ zeitwerk (~> 2.2, >= 2.2.2)
16
17
  ast (2.4.0)
17
18
  byebug (10.0.2)
18
19
  coderay (1.1.2)
19
- concurrent-ruby (1.1.3)
20
+ concurrent-ruby (1.1.6)
20
21
  diff-lcs (1.3)
21
- dry-initializer (2.5.0)
22
- google-protobuf (3.6.1)
23
- googleapis-common-protos-types (1.0.2)
24
- google-protobuf (~> 3.0)
25
- grpc (1.17.0)
26
- google-protobuf (~> 3.1)
27
- googleapis-common-protos-types (~> 1.0.0)
28
- grpc-tools (1.17.0)
29
- gruf (2.5.1)
30
- activesupport
31
- concurrent-ruby
22
+ dry-initializer (3.0.3)
23
+ google-protobuf (3.12.4)
24
+ googleapis-common-protos-types (1.0.5)
25
+ google-protobuf (~> 3.11)
26
+ grpc (1.30.2)
27
+ google-protobuf (~> 3.12)
28
+ googleapis-common-protos-types (~> 1.0)
29
+ grpc-tools (1.30.2)
30
+ gruf (2.8.1)
31
+ activesupport (> 4)
32
+ concurrent-ruby (> 1)
32
33
  grpc (~> 1.10)
33
34
  grpc-tools (~> 1.10)
34
35
  slop (~> 4.6)
35
- i18n (1.2.0)
36
+ i18n (1.8.5)
36
37
  concurrent-ruby (~> 1.0)
37
38
  jaro_winkler (1.5.1)
38
39
  method_source (0.9.0)
39
- minitest (5.11.3)
40
+ minitest (5.14.1)
40
41
  parallel (1.12.1)
41
42
  parser (2.5.1.2)
42
43
  ast (~> 2.4.0)
@@ -73,20 +74,21 @@ GEM
73
74
  rubocop-rspec (1.24.0)
74
75
  rubocop (>= 0.53.0)
75
76
  ruby-progressbar (1.9.0)
76
- slop (4.6.2)
77
+ slop (4.8.2)
77
78
  thread_safe (0.3.6)
78
- tzinfo (1.2.5)
79
+ tzinfo (1.2.7)
79
80
  thread_safe (~> 0.1)
80
81
  unicode-display_width (1.4.0)
81
- yabeda (0.1.2)
82
+ yabeda (0.6.1)
82
83
  concurrent-ruby
83
84
  dry-initializer
85
+ zeitwerk (2.4.0)
84
86
 
85
87
  PLATFORMS
86
88
  ruby
87
89
 
88
90
  DEPENDENCIES
89
- bundler (~> 1.16)
91
+ bundler (~> 2.1)
90
92
  pry
91
93
  pry-byebug
92
94
  rake (~> 10.0)
@@ -96,4 +98,4 @@ DEPENDENCIES
96
98
  yabeda-gruf!
97
99
 
98
100
  BUNDLED WITH
99
- 1.17.2
101
+ 2.1.4
data/README.md CHANGED
@@ -16,12 +16,15 @@ And then execute:
16
16
 
17
17
  ## Usage
18
18
 
19
- Add `Yabeda::Gruf::ServerInterceptor` in gruf configuration.
19
+ Before server starts, `Yabeda.configure!` will be executed!
20
+
21
+ Add `Yabeda::Gruf::ServerInterceptor` and `Yabeda::Gruf::ServerHook` in gruf configuration.
20
22
  Preferably at the beginning of interceptor chain.
21
23
 
22
24
  ```ruby
23
25
  Gruf.configure do |c|
24
26
  c.interceptors.use(Yabeda::Gruf::ServerInterceptor)
27
+ c.hooks.use(Yabeda::Gruf::ServerHook)
25
28
  end
26
29
  ```
27
30
 
@@ -5,6 +5,8 @@ require 'yabeda'
5
5
  require 'gruf'
6
6
 
7
7
  require 'yabeda/gruf/server_interceptor'
8
+ require 'yabeda/gruf/server_hook'
9
+ require 'yabeda/gruf/stats_collector'
8
10
 
9
11
  module Yabeda
10
12
  module Gruf
@@ -14,6 +16,8 @@ module Yabeda
14
16
  ].freeze
15
17
 
16
18
  class << self
19
+ attr_accessor :gruf_server
20
+
17
21
  def install!
18
22
  configure_yabeda!
19
23
  end
@@ -22,12 +26,24 @@ module Yabeda
22
26
 
23
27
  def configure_yabeda!
24
28
  Yabeda.configure do
25
- group :gruf
26
-
27
- # server
28
- counter :served_requests_total, comment: 'A counter of the total number of gRPC requests processed.'
29
- histogram :served_request_duration, unit: :seconds, buckets: LONG_RUNNING_REQUEST_BUCKETS,
30
- comment: 'A histogram of the response latency.'
29
+ group :gruf do
30
+
31
+ # server interceptor
32
+ counter :served_requests_total, comment: 'A counter of the total number of gRPC requests processed.'
33
+ histogram :served_request_duration, unit: :seconds, buckets: LONG_RUNNING_REQUEST_BUCKETS,
34
+ comment: 'A histogram of the response latency.'
35
+
36
+ # server collector
37
+ gauge :pool_jobs_waiting_total, comment: 'Number of jobs in thread pool waiting'
38
+ gauge :pool_ready_workers_total, comment: 'Number of non-busy workers in thread pool'
39
+ gauge :pool_workers_total, comment: 'Total number of workers in thread pool'
40
+ gauge :pool_initial_size, comment: 'Initial size of thread pool'
41
+ gauge :poll_period, comment: 'Polling period for thread pool'
42
+ end
43
+
44
+ collect do
45
+ Yabeda::Gruf::StatsCollector.new.collect! if Yabeda::Gruf.gruf_server
46
+ end
31
47
  end
32
48
  end
33
49
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yabeda
4
+ module Gruf
5
+ class ServerHook < ::Gruf::Hooks::Base
6
+ def before_server_start(server:)
7
+ Yabeda::Gruf.gruf_server = server
8
+ Yabeda.configure! unless Yabeda.already_configured?
9
+ end
10
+ end
11
+ end
12
+ end
@@ -19,8 +19,8 @@ module Yabeda
19
19
 
20
20
  l = labels(response, error)
21
21
 
22
- Yabeda.gruf_served_requests_total.increment(l)
23
- Yabeda.gruf_served_request_duration.measure(l, stop_time - start_time)
22
+ Yabeda.gruf.served_requests_total.increment(l)
23
+ Yabeda.gruf.served_request_duration.measure(l, stop_time - start_time)
24
24
 
25
25
  raise error if error
26
26
  response
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yabeda
4
+ module Gruf
5
+ class StatsCollector
6
+
7
+ def collect!
8
+ return unless server
9
+
10
+ server.instance_variable_get(:@run_mutex).synchronize { measure_metrics }
11
+ end
12
+
13
+ private
14
+
15
+ def measure_metrics
16
+ return unless pool
17
+
18
+ Yabeda.gruf.pool_jobs_waiting_total.set({}, pool.jobs_waiting.to_i)
19
+ Yabeda.gruf.pool_ready_workers_total.set({}, pool.instance_variable_get(:@ready_workers)&.size)
20
+ Yabeda.gruf.pool_workers_total.set({}, pool.instance_variable_get(:@workers)&.size)
21
+ Yabeda.gruf.pool_initial_size.set({}, server.instance_variable_get(:@pool_size)&.to_i)
22
+ Yabeda.gruf.poll_period.set({}, server.instance_variable_get(:@poll_period)&.to_i)
23
+ end
24
+
25
+ def pool
26
+ @pool ||= server&.instance_variable_get(:@pool)
27
+ end
28
+
29
+ def server
30
+ @server ||= Yabeda::Gruf.gruf_server&.server
31
+ end
32
+ end
33
+ end
34
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Gruf
5
- VERSION = '1.0.0'
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  end
@@ -24,10 +24,10 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_dependency 'gruf'
27
+ spec.add_dependency 'gruf', '>= 2.7.0'
28
28
  spec.add_dependency 'yabeda'
29
29
 
30
- spec.add_development_dependency 'bundler', '~> 1.16'
30
+ spec.add_development_dependency 'bundler', '~> 2.1'
31
31
  spec.add_development_dependency 'rake', '~> 10.0'
32
32
  spec.add_development_dependency 'rspec', '~> 3.0'
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-gruf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kruczjak
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-13 00:00:00.000000000 Z
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gruf
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 2.7.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 2.7.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: yabeda
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.16'
47
+ version: '2.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.16'
54
+ version: '2.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -99,14 +99,16 @@ files:
99
99
  - bin/console
100
100
  - bin/setup
101
101
  - lib/yabeda/gruf.rb
102
+ - lib/yabeda/gruf/server_hook.rb
102
103
  - lib/yabeda/gruf/server_interceptor.rb
104
+ - lib/yabeda/gruf/stats_collector.rb
103
105
  - lib/yabeda/gruf/version.rb
104
106
  - yabeda-gruf.gemspec
105
107
  homepage: https://boostcom.no
106
108
  licenses:
107
109
  - MIT
108
110
  metadata: {}
109
- post_install_message:
111
+ post_install_message:
110
112
  rdoc_options: []
111
113
  require_paths:
112
114
  - lib
@@ -121,9 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  - !ruby/object:Gem::Version
122
124
  version: '0'
123
125
  requirements: []
124
- rubyforge_project:
125
- rubygems_version: 2.7.6
126
- signing_key:
126
+ rubygems_version: 3.1.2
127
+ signing_key:
127
128
  specification_version: 4
128
129
  summary: Yabeda exporter for gruf
129
130
  test_files: []