gitlab-exporter 16.3.1 → 16.4.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/Gemfile.lock +6 -6
- data/config/gitlab-exporter.yml.example +5 -0
- data/gitlab-exporter.gemspec +1 -1
- data/lib/gitlab_exporter/sidekiq.rb +26 -0
- data/lib/gitlab_exporter/version.rb +1 -1
- data/spec/sidekiq_spec.rb +94 -0
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1825ce6b93a9f8c4717470772eee4e887519a735209c2575c1768302fc7390be
|
|
4
|
+
data.tar.gz: 2ba4a913855b75c73ba9c79a9d2332148835bec68931d5382375d8feef571f47
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e38f6f12cae4a6e1bbda9f567788523e865d2dbd5609b3f37823269352f0c3cc31e12bc16ec79e43c745cd10d3e388bcef71d4f29e2ea41e1b09a3d02023e63
|
|
7
|
+
data.tar.gz: 2d1ea6f2a7f12249d15de2edddc21a45967daa61cbf44b708b4bdb283d05ae0cc90c71372550a7798d782fab0f61c59bf13e2c7730eaeaf79a2776b082c14968
|
data/Gemfile.lock
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
gitlab-exporter (16.
|
|
4
|
+
gitlab-exporter (16.4.0)
|
|
5
5
|
connection_pool (= 2.5.5)
|
|
6
6
|
deep_merge (~> 1.2.2)
|
|
7
7
|
faraday (= 2.14.0)
|
|
8
|
-
pg (= 1.6.
|
|
8
|
+
pg (= 1.6.3)
|
|
9
9
|
puma (= 7.1.0)
|
|
10
10
|
quantile (= 0.2.1)
|
|
11
11
|
redis (= 4.8.1)
|
|
@@ -38,7 +38,7 @@ GEM
|
|
|
38
38
|
parser (3.3.9.0)
|
|
39
39
|
ast (~> 2.4.1)
|
|
40
40
|
racc
|
|
41
|
-
pg (1.6.
|
|
41
|
+
pg (1.6.3)
|
|
42
42
|
prism (1.4.0)
|
|
43
43
|
puma (7.1.0)
|
|
44
44
|
nio4r (~> 2.0)
|
|
@@ -66,7 +66,7 @@ GEM
|
|
|
66
66
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
67
67
|
rspec-support (~> 3.12.0)
|
|
68
68
|
rspec-support (3.12.0)
|
|
69
|
-
rubocop (1.
|
|
69
|
+
rubocop (1.82.1)
|
|
70
70
|
json (~> 2.3)
|
|
71
71
|
language_server-protocol (~> 3.17.0.2)
|
|
72
72
|
lint_roller (~> 1.1.0)
|
|
@@ -74,10 +74,10 @@ GEM
|
|
|
74
74
|
parser (>= 3.3.0.2)
|
|
75
75
|
rainbow (>= 2.2.2, < 4.0)
|
|
76
76
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
77
|
-
rubocop-ast (>= 1.
|
|
77
|
+
rubocop-ast (>= 1.48.0, < 2.0)
|
|
78
78
|
ruby-progressbar (~> 1.7)
|
|
79
79
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
80
|
-
rubocop-ast (1.
|
|
80
|
+
rubocop-ast (1.48.0)
|
|
81
81
|
parser (>= 3.3.7.2)
|
|
82
82
|
prism (~> 1.4)
|
|
83
83
|
ruby-progressbar (1.13.0)
|
|
@@ -113,6 +113,11 @@ probes:
|
|
|
113
113
|
# port: 26381
|
|
114
114
|
# redis_sentinel_username: 'redis-sentinel-username'
|
|
115
115
|
# redis_sentinel_password: 'redis-sentinel-password'
|
|
116
|
+
# Uncomment if SSL parameters are needed
|
|
117
|
+
# redis_ssl_params:
|
|
118
|
+
# ca_file: '/path/to/ca.crt'
|
|
119
|
+
# cert: '/path/to/client.crt'
|
|
120
|
+
# key: '/path/to/client.key'
|
|
116
121
|
|
|
117
122
|
ruby: &ruby
|
|
118
123
|
class_name: RubyProber
|
data/gitlab-exporter.gemspec
CHANGED
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
s.add_runtime_dependency "connection_pool", "2.5.5"
|
|
26
26
|
s.add_runtime_dependency "deep_merge", "~> 1.2.2"
|
|
27
27
|
s.add_runtime_dependency "faraday", "2.14.0"
|
|
28
|
-
s.add_runtime_dependency "pg", "1.6.
|
|
28
|
+
s.add_runtime_dependency "pg", "1.6.3"
|
|
29
29
|
s.add_runtime_dependency "puma", "7.1.0"
|
|
30
30
|
s.add_runtime_dependency "quantile", "0.2.1"
|
|
31
31
|
s.add_runtime_dependency "redis", "4.8.1"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require "openssl"
|
|
1
2
|
require "sidekiq/api"
|
|
2
3
|
require "sidekiq/scheduled"
|
|
3
4
|
require "digest"
|
|
@@ -204,6 +205,7 @@ module GitLab
|
|
|
204
205
|
options[credential] = @opts[:"redis_#{credential}"] if @opts.key?(:"redis_#{credential}")
|
|
205
206
|
end
|
|
206
207
|
|
|
208
|
+
options[:ssl_params] = parse_ssl_params(@opts[:redis_ssl_params]) if @opts.key?(:redis_ssl_params)
|
|
207
209
|
options[:id] = nil unless redis_enable_client?
|
|
208
210
|
options
|
|
209
211
|
end
|
|
@@ -216,6 +218,9 @@ module GitLab
|
|
|
216
218
|
sentinels.each do |sentinel_config|
|
|
217
219
|
sentinel_config[:username] = @opts[:redis_sentinel_username] if @opts.key?(:redis_sentinel_username)
|
|
218
220
|
sentinel_config[:password] = @opts[:redis_sentinel_password] if @opts.key?(:redis_sentinel_password)
|
|
221
|
+
if sentinel_config.key?(:ssl_params)
|
|
222
|
+
sentinel_config[:ssl_params] = parse_ssl_params(sentinel_config[:ssl_params])
|
|
223
|
+
end
|
|
219
224
|
end
|
|
220
225
|
|
|
221
226
|
sentinels
|
|
@@ -227,6 +232,27 @@ module GitLab
|
|
|
227
232
|
@opts[:redis_enable_client]
|
|
228
233
|
end
|
|
229
234
|
|
|
235
|
+
# redis v4.5 needs OpenSSL objects for the SSL parameters.
|
|
236
|
+
# redis v5 does not need to do this because is uses redis-client, which
|
|
237
|
+
# already does this: https://github.com/redis-rb/redis-client/blob/2b044dbf6266cbc0b0e52b4b9d6940dacb25ccf3/lib/redis_client/ruby_connection.rb#L14-L39
|
|
238
|
+
def parse_ssl_params(ssl_params)
|
|
239
|
+
params = ssl_params&.dup || {}
|
|
240
|
+
|
|
241
|
+
cert = params[:cert]
|
|
242
|
+
if cert.is_a?(String)
|
|
243
|
+
cert = File.read(cert) if File.exist?(cert)
|
|
244
|
+
params[:cert] = OpenSSL::X509::Certificate.new(cert)
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
key = params[:key]
|
|
248
|
+
if key.is_a?(String)
|
|
249
|
+
key = File.read(key) if File.exist?(key)
|
|
250
|
+
params[:key] = OpenSSL::PKey.read(key)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
params
|
|
254
|
+
end
|
|
255
|
+
|
|
230
256
|
def connected?
|
|
231
257
|
return @connected unless @connected.nil?
|
|
232
258
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "gitlab_exporter/sidekiq"
|
|
3
|
+
require "tempfile"
|
|
4
|
+
require "openssl"
|
|
5
|
+
|
|
6
|
+
describe GitLab::Exporter::SidekiqProber do
|
|
7
|
+
let(:metrics) { GitLab::Exporter::PrometheusMetrics.new }
|
|
8
|
+
|
|
9
|
+
def create_test_certificate_and_key
|
|
10
|
+
key = OpenSSL::PKey::RSA.new(2048)
|
|
11
|
+
cert = OpenSSL::X509::Certificate.new
|
|
12
|
+
cert.version = 2
|
|
13
|
+
cert.serial = 1
|
|
14
|
+
cert.subject = OpenSSL::X509::Name.parse("CN=localhost")
|
|
15
|
+
cert.issuer = cert.subject
|
|
16
|
+
cert.public_key = key.public_key
|
|
17
|
+
cert.not_before = Time.now
|
|
18
|
+
cert.not_after = Time.now + 365 * 24 * 60 * 60
|
|
19
|
+
cert.sign(key, OpenSSL::Digest.new("SHA256"))
|
|
20
|
+
[cert, key]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "#redis_options" do
|
|
24
|
+
it "includes ssl_params from file paths" do
|
|
25
|
+
cert, key = create_test_certificate_and_key
|
|
26
|
+
|
|
27
|
+
cert_file = Tempfile.new("cert.crt")
|
|
28
|
+
key_file = Tempfile.new("key.key")
|
|
29
|
+
|
|
30
|
+
cert_file.write(cert.to_pem)
|
|
31
|
+
cert_file.rewind
|
|
32
|
+
key_file.write(key.to_pem)
|
|
33
|
+
key_file.rewind
|
|
34
|
+
|
|
35
|
+
prober = described_class.new(
|
|
36
|
+
metrics: metrics,
|
|
37
|
+
redis_url: "rediss://localhost:6380",
|
|
38
|
+
redis_ssl_params: { cert: cert_file.path, key: key_file.path }
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
options = prober.send(:redis_options)
|
|
42
|
+
|
|
43
|
+
expect(options[:url]).to eq("rediss://localhost:6380")
|
|
44
|
+
expect(options[:ssl_params]).to be_a(Hash)
|
|
45
|
+
expect(options[:ssl_params][:cert]).to be_a(OpenSSL::X509::Certificate)
|
|
46
|
+
expect(options[:ssl_params][:key]).to be_a(OpenSSL::PKey::RSA)
|
|
47
|
+
|
|
48
|
+
cert_file.close
|
|
49
|
+
key_file.close
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "includes ssl_params when already parsed" do
|
|
53
|
+
cert, key = create_test_certificate_and_key
|
|
54
|
+
|
|
55
|
+
prober = described_class.new(
|
|
56
|
+
metrics: metrics,
|
|
57
|
+
redis_url: "rediss://localhost:6380",
|
|
58
|
+
redis_ssl_params: { cert: cert, key: key }
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
options = prober.send(:redis_options)
|
|
62
|
+
|
|
63
|
+
expect(options[:url]).to eq("rediss://localhost:6380")
|
|
64
|
+
expect(options[:ssl_params][:cert]).to equal(cert)
|
|
65
|
+
expect(options[:ssl_params][:key]).to equal(key)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "excludes ssl_params when not provided" do
|
|
69
|
+
prober = described_class.new(
|
|
70
|
+
metrics: metrics,
|
|
71
|
+
redis_url: "redis://localhost:6379"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
options = prober.send(:redis_options)
|
|
75
|
+
|
|
76
|
+
expect(options[:url]).to eq("redis://localhost:6379")
|
|
77
|
+
expect(options).not_to have_key(:ssl_params)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "includes credentials when provided" do
|
|
81
|
+
prober = described_class.new(
|
|
82
|
+
metrics: metrics,
|
|
83
|
+
redis_url: "redis://localhost:6379",
|
|
84
|
+
redis_username: "user",
|
|
85
|
+
redis_password: "pass"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
options = prober.send(:redis_options)
|
|
89
|
+
|
|
90
|
+
expect(options[:username]).to eq("user")
|
|
91
|
+
expect(options[:password]).to eq("pass")
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gitlab-exporter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 16.
|
|
4
|
+
version: 16.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pablo Carranza
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - '='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 1.6.
|
|
61
|
+
version: 1.6.3
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - '='
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 1.6.
|
|
68
|
+
version: 1.6.3
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: puma
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -255,6 +255,7 @@ files:
|
|
|
255
255
|
- spec/memstats_spec.rb
|
|
256
256
|
- spec/prometheus_metrics_spec.rb
|
|
257
257
|
- spec/ruby_spec.rb
|
|
258
|
+
- spec/sidekiq_spec.rb
|
|
258
259
|
- spec/spec_helper.rb
|
|
259
260
|
- spec/util_spec.rb
|
|
260
261
|
homepage: https://gitlab.com/gitlab-org/ruby/gems/gitlab-exporter
|
|
@@ -296,5 +297,6 @@ test_files:
|
|
|
296
297
|
- spec/memstats_spec.rb
|
|
297
298
|
- spec/prometheus_metrics_spec.rb
|
|
298
299
|
- spec/ruby_spec.rb
|
|
300
|
+
- spec/sidekiq_spec.rb
|
|
299
301
|
- spec/spec_helper.rb
|
|
300
302
|
- spec/util_spec.rb
|