gruf-prometheus 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/gruf-prometheus.gemspec +1 -1
- data/lib/gruf/prometheus.rb +2 -2
- data/lib/gruf/prometheus/collector.rb +60 -0
- data/lib/gruf/prometheus/hook.rb +6 -4
- data/lib/gruf/prometheus/type_collector.rb +57 -0
- data/lib/gruf/prometheus/version.rb +1 -1
- metadata +6 -6
- data/lib/gruf/prometheus/collectors/grpc.rb +0 -111
- data/lib/gruf/prometheus/type_collectors/grpc.rb +0 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faf2407a0d57a111725037bef23e55ca38ec318ef0307f06f729042dcaab9561
|
4
|
+
data.tar.gz: 561ee316f087f56e485d1ea3debd3c34df3764100babfce3576cfc8e64a19a3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4425dcd1a8861c7f6fefbf27b4cbebe782a9ef246b5819e469944c2ff032a1aef75eac4bd75d0ff5b8b7bfa3de09ad7a7a5062f34d207b713cfe07573b1b3c63
|
7
|
+
data.tar.gz: 18e6cf9983f630798fb73f564fcd50a2f6b3a3852ffe07e93d755f4f73775880373fd82e17f282a487c80877a35f33477b5cf6397754fd16f630ff3bebbed829
|
data/CHANGELOG.md
CHANGED
data/gruf-prometheus.gemspec
CHANGED
@@ -42,5 +42,5 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_development_dependency 'pry', '>= 0.12'
|
43
43
|
|
44
44
|
spec.add_runtime_dependency 'gruf', '>= 2.7'
|
45
|
-
spec.add_runtime_dependency 'bc-prometheus-ruby', '~> 0.
|
45
|
+
spec.add_runtime_dependency 'bc-prometheus-ruby', '~> 0.2'
|
46
46
|
end
|
data/lib/gruf/prometheus.rb
CHANGED
@@ -27,8 +27,8 @@ require 'bigcommerce/prometheus'
|
|
27
27
|
|
28
28
|
require_relative 'prometheus/version'
|
29
29
|
require_relative 'prometheus/configuration'
|
30
|
-
require_relative 'prometheus/
|
31
|
-
require_relative 'prometheus/
|
30
|
+
require_relative 'prometheus/collector'
|
31
|
+
require_relative 'prometheus/type_collector'
|
32
32
|
require_relative 'prometheus/hook'
|
33
33
|
|
34
34
|
module Gruf
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2019-present, BigCommerce Pty. Ltd. All rights reserved
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
6
|
+
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
7
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
+
# persons to whom the Software is furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
11
|
+
# Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
14
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
15
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
16
|
+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
|
+
#
|
18
|
+
module Gruf
|
19
|
+
module Prometheus
|
20
|
+
##
|
21
|
+
# Prometheus instrumentor for gRPC servers
|
22
|
+
#
|
23
|
+
class Collector < Bigcommerce::Prometheus::Collectors::Base
|
24
|
+
def type
|
25
|
+
'grpc'
|
26
|
+
end
|
27
|
+
|
28
|
+
def collect(metrics = {})
|
29
|
+
metrics[:type] = 'grpc'
|
30
|
+
rpc_server = grpc_server
|
31
|
+
return metrics unless rpc_server
|
32
|
+
|
33
|
+
rpc_server.instance_variable_get(:@run_mutex).synchronize do
|
34
|
+
collect_server_metrics(rpc_server, metrics)
|
35
|
+
end
|
36
|
+
metrics
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# @param [GRPC::RpcServer] rpc_server
|
41
|
+
# @param [Hash] metrics
|
42
|
+
#
|
43
|
+
def collect_server_metrics(rpc_server, metrics)
|
44
|
+
pool = rpc_server.instance_variable_get(:@pool)
|
45
|
+
metrics[:pool_jobs_waiting_total] = pool.jobs_waiting.to_i
|
46
|
+
metrics[:pool_ready_workers_total] = pool.instance_variable_get(:@ready_workers).size
|
47
|
+
metrics[:pool_workers_total] = pool.instance_variable_get(:@workers)&.size
|
48
|
+
metrics[:pool_initial_size] = rpc_server.instance_variable_get(:@pool_size).to_i
|
49
|
+
metrics[:poll_period] = rpc_server.instance_variable_get(:@poll_period).to_i
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# @return [GRPC::RpcServer]
|
54
|
+
#
|
55
|
+
def grpc_server
|
56
|
+
@options.fetch(:server, nil)&.server
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/gruf/prometheus/hook.rb
CHANGED
@@ -28,7 +28,7 @@ module Gruf
|
|
28
28
|
#
|
29
29
|
def before_server_start(server:)
|
30
30
|
logger.info "[gruf-prometheus][#{::Gruf::Prometheus.process_name}] Starting #{server.class}"
|
31
|
-
prometheus_server.add_type_collector(::Gruf::Prometheus::
|
31
|
+
prometheus_server.add_type_collector(::Gruf::Prometheus::TypeCollector.new)
|
32
32
|
prometheus_server.add_type_collector(::PrometheusExporter::Server::ActiveRecordCollector.new)
|
33
33
|
prometheus_server.start
|
34
34
|
sleep 2 unless ENV['RACK_ENV'] == 'test' # wait for server to come online
|
@@ -58,8 +58,10 @@ module Gruf
|
|
58
58
|
client: ::Bigcommerce::Prometheus.client,
|
59
59
|
frequency: ::Gruf::Prometheus.collection_frequency
|
60
60
|
)
|
61
|
-
::Gruf::Prometheus::
|
62
|
-
|
61
|
+
::Gruf::Prometheus::Collector.start(
|
62
|
+
options: {
|
63
|
+
server: server
|
64
|
+
},
|
63
65
|
client: ::Bigcommerce::Prometheus.client,
|
64
66
|
frequency: ::Gruf::Prometheus.collection_frequency
|
65
67
|
)
|
@@ -70,7 +72,7 @@ module Gruf
|
|
70
72
|
#
|
71
73
|
def stop_collectors
|
72
74
|
::PrometheusExporter::Instrumentation::Process.stop
|
73
|
-
::Gruf::Prometheus::
|
75
|
+
::Gruf::Prometheus::Collector.stop
|
74
76
|
end
|
75
77
|
|
76
78
|
##
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2019-present, BigCommerce Pty. Ltd. All rights reserved
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
6
|
+
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
7
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
+
# persons to whom the Software is furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
11
|
+
# Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
14
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
15
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
16
|
+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
|
+
#
|
18
|
+
module Gruf
|
19
|
+
module Prometheus
|
20
|
+
##
|
21
|
+
# Type Collector for prometheus and grpc instrumentation
|
22
|
+
#
|
23
|
+
class TypeCollector < Bigcommerce::Prometheus::TypeCollectors::Base
|
24
|
+
def type
|
25
|
+
'grpc'
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
##
|
31
|
+
# Initialize the collector
|
32
|
+
#
|
33
|
+
def build_metrics
|
34
|
+
{
|
35
|
+
pool_jobs_waiting_total: PrometheusExporter::Metric::Gauge.new('grpc_pool_jobs_waiting_total', 'Number jobs in the gRPC thread pool that are actively waiting'),
|
36
|
+
pool_ready_workers_total: PrometheusExporter::Metric::Gauge.new('grpc_pool_ready_workers_total', 'The amount of non-busy workers in the thread pool'),
|
37
|
+
pool_workers_total: PrometheusExporter::Metric::Gauge.new('grpc_pool_workers_total', 'Number of workers in the gRPC thread pool'),
|
38
|
+
pool_initial_size: PrometheusExporter::Metric::Gauge.new('grpc_pool_initial_size', 'Initial size of the gRPC thread pool'),
|
39
|
+
poll_period: PrometheusExporter::Metric::Gauge.new('grpc_poll_period', 'Polling period for the gRPC thread pool'),
|
40
|
+
thread_pool_exhausted: PrometheusExporter::Metric::Counter.new('grpc_thread_pool_exhausted', 'Times the gRPC thread pool has been exhausted')
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Collect the object into the buffer
|
46
|
+
#
|
47
|
+
def collect_metrics(data: {}, labels: {})
|
48
|
+
metric(:pool_jobs_waiting_total)&.observe(data['pool_jobs_waiting_total'].to_i, labels)
|
49
|
+
metric(:pool_ready_workers_total)&.observe(data['pool_ready_workers_total'].to_i, labels)
|
50
|
+
metric(:pool_workers_total)&.observe(data['pool_workers_total'].to_i, labels)
|
51
|
+
metric(:pool_initial_size)&.observe(data['pool_initial_size'].to_i, labels)
|
52
|
+
metric(:poll_period)&.observe(data['poll_period'].to_i, labels)
|
53
|
+
metric(:thread_pool_exhausted)&.observe(data['thread_pool_exhausted'].to_i, labels)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gruf-prometheus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun McCormick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
145
|
+
version: '0.2'
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
152
|
+
version: '0.2'
|
153
153
|
description: Prometheus support for gruf
|
154
154
|
email:
|
155
155
|
- shaun.mccormick@bigcommerce.com
|
@@ -162,10 +162,10 @@ files:
|
|
162
162
|
- README.md
|
163
163
|
- gruf-prometheus.gemspec
|
164
164
|
- lib/gruf/prometheus.rb
|
165
|
-
- lib/gruf/prometheus/
|
165
|
+
- lib/gruf/prometheus/collector.rb
|
166
166
|
- lib/gruf/prometheus/configuration.rb
|
167
167
|
- lib/gruf/prometheus/hook.rb
|
168
|
-
- lib/gruf/prometheus/
|
168
|
+
- lib/gruf/prometheus/type_collector.rb
|
169
169
|
- lib/gruf/prometheus/version.rb
|
170
170
|
homepage: https://github.com/bigcommerce/gruf-prometheus
|
171
171
|
licenses:
|
@@ -1,111 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2019-present, BigCommerce Pty. Ltd. All rights reserved
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
6
|
-
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
7
|
-
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
-
# persons to whom the Software is furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
11
|
-
# Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
14
|
-
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
15
|
-
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
16
|
-
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
|
-
#
|
18
|
-
module Gruf
|
19
|
-
module Prometheus
|
20
|
-
module Collectors
|
21
|
-
##
|
22
|
-
# Prometheus instrumentor for gRPC servers
|
23
|
-
#
|
24
|
-
class Grpc
|
25
|
-
include Gruf::Loggable
|
26
|
-
|
27
|
-
##
|
28
|
-
# @param [Gruf::Server] server
|
29
|
-
# @param [Gruf::Prometheus::Client] client
|
30
|
-
# @param [Integer] frequency
|
31
|
-
#
|
32
|
-
def initialize(server:, client:, frequency: nil)
|
33
|
-
@server = server
|
34
|
-
@client = client
|
35
|
-
@frequency = frequency || 15
|
36
|
-
end
|
37
|
-
|
38
|
-
##
|
39
|
-
# Start the collector
|
40
|
-
#
|
41
|
-
# @param [Gruf::Server] server
|
42
|
-
# @param [Gruf::Prometheus::Client] client
|
43
|
-
# @param [Integer] frequency
|
44
|
-
#
|
45
|
-
def self.start(server:, client: nil, frequency: nil)
|
46
|
-
stop if @thread
|
47
|
-
|
48
|
-
client ||= Bigcommerce::Prometheus::Client.instance
|
49
|
-
collector = new(server: server, client: client, frequency: frequency)
|
50
|
-
@thread = Thread.new do
|
51
|
-
loop do
|
52
|
-
collector.run
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
##
|
58
|
-
# Stop the collector
|
59
|
-
#
|
60
|
-
def self.stop
|
61
|
-
t = @thread
|
62
|
-
return unless t
|
63
|
-
|
64
|
-
t.kill
|
65
|
-
@thread = nil
|
66
|
-
end
|
67
|
-
|
68
|
-
def run
|
69
|
-
metric = collect
|
70
|
-
logger.debug "[gruf-prometheus] Pushing gruf metrics to type collector: #{metric.inspect}"
|
71
|
-
@client.send_json metric
|
72
|
-
rescue StandardError => e
|
73
|
-
logger.error "[gruf-prometheus] Failed to collect gruf-prometheus stats: #{e.message}"
|
74
|
-
ensure
|
75
|
-
sleep @frequency
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def collect
|
81
|
-
metric = {}
|
82
|
-
metric[:type] = 'grpc'
|
83
|
-
rpc_server = @server.server
|
84
|
-
rpc_server.instance_variable_get(:@run_mutex).synchronize do
|
85
|
-
collect_server_metrics(rpc_server, metric)
|
86
|
-
end
|
87
|
-
metric
|
88
|
-
end
|
89
|
-
|
90
|
-
##
|
91
|
-
# @param [GRPC::RpcServer] rpc_server
|
92
|
-
#
|
93
|
-
def collect_server_metrics(rpc_server, metric)
|
94
|
-
pool = rpc_server.instance_variable_get(:@pool)
|
95
|
-
metric[:pool_jobs_waiting_total] = pool.jobs_waiting.to_i
|
96
|
-
metric[:pool_ready_workers_total] = pool.instance_variable_get(:@ready_workers).size
|
97
|
-
metric[:pool_workers_total] = pool.instance_variable_get(:@workers)&.size
|
98
|
-
metric[:pool_initial_size] = rpc_server.instance_variable_get(:@pool_size).to_i
|
99
|
-
metric[:poll_period] = rpc_server.instance_variable_get(:@poll_period).to_i
|
100
|
-
end
|
101
|
-
|
102
|
-
##
|
103
|
-
# @return [GRPC::RpcServer]
|
104
|
-
#
|
105
|
-
def grpc_server
|
106
|
-
@server.server
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2019-present, BigCommerce Pty. Ltd. All rights reserved
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
6
|
-
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
7
|
-
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
-
# persons to whom the Software is furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
11
|
-
# Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
14
|
-
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
15
|
-
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
16
|
-
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
|
-
#
|
18
|
-
module Gruf
|
19
|
-
module Prometheus
|
20
|
-
module TypeCollectors
|
21
|
-
##
|
22
|
-
# Type Collector for prometheus and grpc instrumentation
|
23
|
-
#
|
24
|
-
class Grpc < PrometheusExporter::Server::TypeCollector
|
25
|
-
##
|
26
|
-
# Initialize the collector
|
27
|
-
#
|
28
|
-
def initialize
|
29
|
-
@pool_jobs_waiting_total = PrometheusExporter::Metric::Gauge.new('grpc_pool_jobs_waiting_total', 'Number jobs in the gRPC thread pool that are actively waiting')
|
30
|
-
@pool_ready_workers_total = PrometheusExporter::Metric::Gauge.new('grpc_pool_ready_workers_total', 'The amount of non-busy workers in the thread pool')
|
31
|
-
@pool_workers_total = PrometheusExporter::Metric::Gauge.new('grpc_pool_workers_total', 'Number of workers in the gRPC thread pool')
|
32
|
-
@pool_initial_size = PrometheusExporter::Metric::Gauge.new('grpc_pool_initial_size', 'Initial size of the gRPC thread pool')
|
33
|
-
@poll_period = PrometheusExporter::Metric::Gauge.new('grpc_poll_period', 'Polling period for the gRPC thread pool')
|
34
|
-
@thread_pool_exhausted = PrometheusExporter::Metric::Counter.new('grpc_thread_pool_exhausted', 'Times the gRPC thread pool has been exhausted')
|
35
|
-
end
|
36
|
-
|
37
|
-
##
|
38
|
-
# @return [String]
|
39
|
-
#
|
40
|
-
def type
|
41
|
-
'grpc'
|
42
|
-
end
|
43
|
-
|
44
|
-
##
|
45
|
-
# @return [Array]
|
46
|
-
#
|
47
|
-
def metrics
|
48
|
-
return [] unless @pool_jobs_waiting_total
|
49
|
-
|
50
|
-
[
|
51
|
-
@pool_jobs_waiting_total,
|
52
|
-
@pool_ready_workers_total,
|
53
|
-
@pool_workers_total,
|
54
|
-
@pool_initial_size,
|
55
|
-
@poll_period,
|
56
|
-
@thread_pool_exhausted
|
57
|
-
]
|
58
|
-
end
|
59
|
-
|
60
|
-
##
|
61
|
-
# Collect the object into the buffer
|
62
|
-
#
|
63
|
-
def collect(obj)
|
64
|
-
default_labels = {}
|
65
|
-
default_labels['environment'] = obj['environment'] if obj['environment']
|
66
|
-
|
67
|
-
custom_labels = obj['custom_labels'] || {}
|
68
|
-
labels = custom_labels.nil? ? default_labels : default_labels.merge(custom_labels)
|
69
|
-
|
70
|
-
@pool_jobs_waiting_total.observe(obj['pool_jobs_waiting_total'].to_i, labels)
|
71
|
-
@pool_ready_workers_total.observe(obj['pool_ready_workers_total'].to_i, labels)
|
72
|
-
@pool_workers_total.observe(obj['pool_workers_total'].to_i, labels)
|
73
|
-
@pool_initial_size.observe(obj['pool_initial_size'].to_i, labels)
|
74
|
-
@poll_period.observe(obj['poll_period'].to_i, labels)
|
75
|
-
@thread_pool_exhausted.observe(obj['thread_pool_exhausted'].to_i, labels)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|