vmpooler 0.14.6 → 0.14.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/vmpooler +14 -5
- data/lib/vmpooler.rb +53 -0
- data/lib/vmpooler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa377464c0b9bfa6ac09d96064dceb410417ddcfc81e2523e5d32e691f7e8091
|
4
|
+
data.tar.gz: d61f1c0ea6fe636b593912cbe26954edd253b07952b999205adf6b9271c8ae3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f5c68048317e9374725e4c5cf71c53d32c28ad3e287b7f82c54a2bb852e039f21b8326fa62160f77dcf7572ed39b4035a005bf214097634844052bab59c828a
|
7
|
+
data.tar.gz: 877db96232be8617987096b227f390a643b788d50971ebc629de7f5aca720cd96202d8d0292ecffa8a7fe2e366ee649f9e2eda59202423929abd94f90beae1cd
|
data/bin/vmpooler
CHANGED
@@ -2,30 +2,39 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'vmpooler'
|
5
|
+
require 'vmpooler/version'
|
5
6
|
|
6
7
|
config = Vmpooler.config
|
8
|
+
logger_file = config[:config]['logfile']
|
9
|
+
prefix = config[:config]['prefix']
|
7
10
|
redis_host = config[:redis]['server']
|
8
11
|
redis_port = config[:redis]['port']
|
9
12
|
redis_password = config[:redis]['password']
|
10
13
|
redis_connection_pool_size = config[:redis]['connection_pool_size']
|
11
14
|
redis_connection_pool_timeout = config[:redis]['connection_pool_timeout']
|
12
15
|
redis_reconnect_attempts = config[:redis]['reconnect_attempts']
|
13
|
-
|
16
|
+
tracing_enabled = config[:tracing]['enabled']
|
17
|
+
tracing_jaeger_host = config[:tracing]['jaeger_host']
|
14
18
|
|
15
19
|
logger = Vmpooler::Logger.new logger_file
|
16
20
|
metrics = Vmpooler::Metrics.init(logger, config)
|
17
21
|
|
22
|
+
version = Vmpooler::VERSION
|
23
|
+
|
24
|
+
startup_args = ARGV
|
25
|
+
Vmpooler.configure_tracing(startup_args, prefix, tracing_enabled, tracing_jaeger_host, version)
|
26
|
+
|
18
27
|
torun_threads = []
|
19
28
|
if ARGV.count == 0
|
20
29
|
torun = %i[api manager]
|
21
30
|
else
|
22
31
|
torun = []
|
23
|
-
torun << :api if ARGV.include?
|
24
|
-
torun << :manager if ARGV.include?
|
32
|
+
torun << :api if ARGV.include?('api')
|
33
|
+
torun << :manager if ARGV.include?('manager')
|
25
34
|
exit(2) if torun.empty?
|
26
35
|
end
|
27
36
|
|
28
|
-
if torun.include?
|
37
|
+
if torun.include?(:api)
|
29
38
|
api = Thread.new do
|
30
39
|
redis = Vmpooler.new_redis(redis_host, redis_port, redis_password)
|
31
40
|
Vmpooler::API.execute(torun, config, redis, metrics, logger)
|
@@ -39,7 +48,7 @@ elsif metrics.respond_to?(:setup_prometheus_metrics)
|
|
39
48
|
torun_threads << prometheus_only_api
|
40
49
|
end
|
41
50
|
|
42
|
-
if torun.include?
|
51
|
+
if torun.include?(:manager)
|
43
52
|
manager = Thread.new do
|
44
53
|
Vmpooler::PoolManager.new(
|
45
54
|
config,
|
data/lib/vmpooler.rb
CHANGED
@@ -15,6 +15,15 @@ module Vmpooler
|
|
15
15
|
require 'timeout'
|
16
16
|
require 'yaml'
|
17
17
|
|
18
|
+
# Dependencies for tracing
|
19
|
+
require 'opentelemetry-api'
|
20
|
+
require 'opentelemetry-instrumentation-concurrent_ruby'
|
21
|
+
require 'opentelemetry-instrumentation-redis'
|
22
|
+
require 'opentelemetry-instrumentation-sinatra'
|
23
|
+
require 'opentelemetry-sdk'
|
24
|
+
require 'opentelemetry/exporter/jaeger'
|
25
|
+
require 'opentelemetry/resource/detectors'
|
26
|
+
|
18
27
|
%w[api metrics logger pool_manager generic_connection_pool].each do |lib|
|
19
28
|
require "vmpooler/#{lib}"
|
20
29
|
end
|
@@ -103,6 +112,10 @@ module Vmpooler
|
|
103
112
|
parsed_config[:graphite]['prefix'] = ENV['GRAPHITE_PREFIX'] if ENV['GRAPHITE_PREFIX']
|
104
113
|
parsed_config[:graphite]['port'] = string_to_int(ENV['GRAPHITE_PORT']) if ENV['GRAPHITE_PORT']
|
105
114
|
|
115
|
+
parsed_config[:tracing] = parsed_config[:tracing] || {}
|
116
|
+
parsed_config[:tracing]['enabled'] = ENV['VMPOOLER_TRACING_ENABLED'] || parsed_config[:tracing]['enabled'] || 'false'
|
117
|
+
parsed_config[:tracing]['jaeger_host'] = ENV['VMPOOLER_TRACING_JAEGER_HOST'] || parsed_config[:tracing]['jaeger_host'] || 'http://localhost:14268/api/traces'
|
118
|
+
|
106
119
|
parsed_config[:auth] = parsed_config[:auth] || {} if ENV['AUTH_PROVIDER']
|
107
120
|
if parsed_config.key? :auth
|
108
121
|
parsed_config[:auth]['provider'] = ENV['AUTH_PROVIDER'] if ENV['AUTH_PROVIDER']
|
@@ -213,4 +226,44 @@ module Vmpooler
|
|
213
226
|
parsed_config[:config]['create_linked_clones'] = ENV['CREATE_LINKED_CLONES'] if ENV['CREATE_LINKED_CLONES'] =~ /true|false/
|
214
227
|
parsed_config[:config]['create_linked_clones'] = true?(parsed_config[:config]['create_linked_clones']) if parsed_config[:config]['create_linked_clones']
|
215
228
|
end
|
229
|
+
|
230
|
+
def self.configure_tracing(startup_args, prefix, tracing_enabled, tracing_jaeger_host, version)
|
231
|
+
if startup_args.length == 1 && startup_args.include?('api')
|
232
|
+
service_name = 'vmpooler-api'
|
233
|
+
elsif startup_args.length == 1 && startup_args.include?('manager')
|
234
|
+
service_name = 'vmpooler-manager'
|
235
|
+
else
|
236
|
+
service_name = 'vmpooler'
|
237
|
+
end
|
238
|
+
|
239
|
+
service_name += "-#{prefix}" unless prefix.empty?
|
240
|
+
|
241
|
+
if tracing_enabled.eql?('false')
|
242
|
+
puts "Exporting of traces has been disabled so the span processor has been se to a 'NoopSpanExporter'"
|
243
|
+
span_processor = OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
|
244
|
+
exporter: OpenTelemetry::SDK::Trace::Export::NoopSpanExporter.new
|
245
|
+
)
|
246
|
+
else
|
247
|
+
puts "Exporting of traces will be done over HTTP in binary Thrift format to #{tracing_jaeger_host}"
|
248
|
+
span_processor = OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
|
249
|
+
exporter: OpenTelemetry::Exporter::Jaeger::CollectorExporter.new(endpoint: tracing_jaeger_host)
|
250
|
+
)
|
251
|
+
end
|
252
|
+
|
253
|
+
OpenTelemetry::SDK.configure do |c|
|
254
|
+
c.use 'OpenTelemetry::Instrumentation::Sinatra'
|
255
|
+
c.use 'OpenTelemetry::Instrumentation::ConcurrentRuby'
|
256
|
+
c.use 'OpenTelemetry::Instrumentation::Redis'
|
257
|
+
|
258
|
+
c.add_span_processor(span_processor)
|
259
|
+
|
260
|
+
c.resource = OpenTelemetry::Resource::Detectors::AutoDetector.detect
|
261
|
+
c.resource = OpenTelemetry::SDK::Resources::Resource.create(
|
262
|
+
{
|
263
|
+
OpenTelemetry::SDK::Resources::Constants::SERVICE_RESOURCE[:name] => service_name,
|
264
|
+
OpenTelemetry::SDK::Resources::Constants::SERVICE_RESOURCE[:version] => version
|
265
|
+
}
|
266
|
+
)
|
267
|
+
end
|
268
|
+
end
|
216
269
|
end
|
data/lib/vmpooler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmpooler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pickup
|