gitlab-exporter 11.0.1 → 11.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +8 -1
- data/.ruby-version +1 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +11 -9
- data/README.md +10 -3
- data/gitlab-exporter.gemspec +1 -1
- data/lib/gitlab_exporter/database/base.rb +2 -2
- data/lib/gitlab_exporter/database/bloat.rb +4 -5
- data/lib/gitlab_exporter/database/ci_builds.rb +5 -9
- data/lib/gitlab_exporter/database/remote_mirrors.rb +3 -3
- data/lib/gitlab_exporter/database/row_count.rb +22 -9
- data/lib/gitlab_exporter/database/tuple_stats.rb +2 -2
- data/lib/gitlab_exporter/git.rb +6 -6
- data/lib/gitlab_exporter/prober.rb +2 -2
- data/lib/gitlab_exporter/process.rb +3 -3
- data/lib/gitlab_exporter/ruby.rb +2 -2
- data/lib/gitlab_exporter/sidekiq.rb +23 -1
- data/lib/gitlab_exporter/version.rb +1 -1
- data/lib/gitlab_exporter/web_exporter.rb +1 -1
- data/spec/database/bloat_spec.rb +3 -3
- data/spec/database/ci_builds_spec.rb +6 -5
- data/spec/git_spec.rb +3 -3
- data/spec/ruby_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1629fb16b7451c28e085202cc001961dc3f1ac66308146ca992a7eeaf179c6e2
|
4
|
+
data.tar.gz: a6158d5da5323e132a4a07e9b33238bb6b224658bc60a6885225c6d6a3729698
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1f03be5bb43004977d466b5dd4985a1626cc1cf430ee4d2137ad1c5983da527521ca3b3785e28e7daf20f18405b1bf43e9964106d60900b5c26e102e035d7c6
|
7
|
+
data.tar.gz: 5433100b784c35f2c66e676e2c361ed6945fbcd4cc29d77be831f4f0c7d2f2d4a9b6271aeb8492c7af13f266975e053322a84e288c12502ba65ff03996f13a25
|
data/.gitlab-ci.yml
CHANGED
@@ -6,12 +6,15 @@ include:
|
|
6
6
|
- template: Security/SAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml
|
7
7
|
- template: Security/Secret-Detection.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/ci/templates/Security/Secret-Detection.gitlab-ci.yml
|
8
8
|
|
9
|
+
variables:
|
10
|
+
RUBY_VERSION: "2.7"
|
11
|
+
|
9
12
|
stages:
|
10
13
|
- test
|
11
14
|
- dast
|
12
15
|
|
13
16
|
default:
|
14
|
-
image: ruby
|
17
|
+
image: ruby:${RUBY_VERSION}
|
15
18
|
cache:
|
16
19
|
paths:
|
17
20
|
- vendor
|
@@ -36,6 +39,10 @@ rspec:
|
|
36
39
|
script:
|
37
40
|
- bundle exec rspec spec -f d -c
|
38
41
|
before_script: *before_scripts
|
42
|
+
parallel:
|
43
|
+
matrix:
|
44
|
+
- RUBY_VERSION: "2.7"
|
45
|
+
- RUBY_VERSION: "3.0"
|
39
46
|
|
40
47
|
rubocop:
|
41
48
|
script:
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.7.
|
1
|
+
2.7.4
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gitlab-exporter (11.0
|
4
|
+
gitlab-exporter (11.4.0)
|
5
5
|
connection_pool (= 2.2.5)
|
6
6
|
pg (= 1.2.3)
|
7
7
|
puma (= 5.3.2)
|
@@ -9,7 +9,7 @@ PATH
|
|
9
9
|
redis (= 4.1.4)
|
10
10
|
redis-namespace (= 1.6.0)
|
11
11
|
sidekiq (= 5.2.9)
|
12
|
-
sinatra (
|
12
|
+
sinatra (~> 2.1.0)
|
13
13
|
|
14
14
|
GEM
|
15
15
|
remote: https://rubygems.org/
|
@@ -19,7 +19,7 @@ GEM
|
|
19
19
|
diff-lcs (1.3)
|
20
20
|
mustermann (1.1.1)
|
21
21
|
ruby2_keywords (~> 0.0.1)
|
22
|
-
nio4r (2.5.
|
22
|
+
nio4r (2.5.8)
|
23
23
|
parallel (1.20.1)
|
24
24
|
parser (3.0.0.0)
|
25
25
|
ast (~> 2.4.1)
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
nio4r (~> 2.0)
|
29
29
|
quantile (0.2.1)
|
30
30
|
rack (2.2.3)
|
31
|
-
rack-protection (2.0
|
31
|
+
rack-protection (2.1.0)
|
32
32
|
rack
|
33
33
|
rainbow (3.0.0)
|
34
34
|
redis (4.1.4)
|
@@ -61,19 +61,20 @@ GEM
|
|
61
61
|
rubocop-ast (1.4.0)
|
62
62
|
parser (>= 2.7.1.5)
|
63
63
|
ruby-progressbar (1.11.0)
|
64
|
-
ruby2_keywords (0.0.
|
64
|
+
ruby2_keywords (0.0.5)
|
65
65
|
sidekiq (5.2.9)
|
66
66
|
connection_pool (~> 2.2, >= 2.2.2)
|
67
67
|
rack (~> 2.0)
|
68
68
|
rack-protection (>= 1.5.0)
|
69
69
|
redis (>= 3.3.5, < 4.2)
|
70
|
-
sinatra (2.0
|
70
|
+
sinatra (2.1.0)
|
71
71
|
mustermann (~> 1.0)
|
72
|
-
rack (~> 2.
|
73
|
-
rack-protection (= 2.0
|
72
|
+
rack (~> 2.2)
|
73
|
+
rack-protection (= 2.1.0)
|
74
74
|
tilt (~> 2.0)
|
75
75
|
tilt (2.0.10)
|
76
76
|
unicode-display_width (1.7.0)
|
77
|
+
webrick (1.7.0)
|
77
78
|
|
78
79
|
PLATFORMS
|
79
80
|
ruby
|
@@ -83,6 +84,7 @@ DEPENDENCIES
|
|
83
84
|
rspec (~> 3.5)
|
84
85
|
rspec-expectations (~> 3.7.0)
|
85
86
|
rubocop (~> 0.42)
|
87
|
+
webrick (~> 1.7)
|
86
88
|
|
87
89
|
BUNDLED WITH
|
88
|
-
2.
|
90
|
+
2.2.22
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ metrics.
|
|
34
34
|
`git_pull_time_milliseconds`, `git_push_time_milliseconds`
|
35
35
|
* git processes stats (see Process below)
|
36
36
|
1. [Sidekiq](lib/gitlab_exporter/sidekiq.rb)
|
37
|
-
* Stats
|
37
|
+
* Stats (probe_stats)
|
38
38
|
* `sidekiq_jobs_processed_total`
|
39
39
|
* `sidekiq_jobs_failed_total`
|
40
40
|
* `sidekiq_jobs_enqueued_size`
|
@@ -44,14 +44,21 @@ metrics.
|
|
44
44
|
* `sidekiq_default_queue_latency_seconds`
|
45
45
|
* `sidekiq_processes_size`
|
46
46
|
* `sidekiq_workers_size`
|
47
|
-
* Queues
|
47
|
+
* Queues (probe_queues)
|
48
48
|
* `sidekiq_queue_size`
|
49
49
|
* `sidekiq_queue_paused`
|
50
50
|
* `sidekiq_queue_latency_seconds`
|
51
|
-
* Jobs
|
51
|
+
* Jobs (probe_jobs_limit)
|
52
52
|
* `sidekiq_enqueued_jobs`
|
53
|
+
* Workers (probe_workers)
|
53
54
|
* `sidekiq_running_jobs`
|
55
|
+
* Retries (probe_retries)
|
54
56
|
* `sidekiq_to_be_retried_jobs`
|
57
|
+
* Future Sets (probe_future_sets)
|
58
|
+
* `sidekiq_schedule_set_processing_delay_seconds`
|
59
|
+
* `sidekiq_schedule_set_backlog_count`
|
60
|
+
* `sidekiq_retry_set_processing_delay_seconds`
|
61
|
+
* `sidekiq_retry_set_backlog_count`
|
55
62
|
|
56
63
|
### Setup with GitLab Development Kit
|
57
64
|
|
data/gitlab-exporter.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_runtime_dependency "redis", "4.1.4"
|
28
28
|
s.add_runtime_dependency "redis-namespace", "1.6.0"
|
29
29
|
s.add_runtime_dependency "sidekiq", "5.2.9"
|
30
|
-
s.add_runtime_dependency "sinatra", "2.0
|
30
|
+
s.add_runtime_dependency "sinatra", "~> 2.1.0"
|
31
31
|
|
32
32
|
s.add_development_dependency "rspec", "~> 3.7.0"
|
33
33
|
s.add_development_dependency "rspec-expectations", "~> 3.7.0"
|
@@ -41,8 +41,8 @@ module GitLab
|
|
41
41
|
conn.type_map_for_results = tm
|
42
42
|
end
|
43
43
|
|
44
|
-
def initialize(
|
45
|
-
@connection_string =
|
44
|
+
def initialize(connection_string:, logger: nil, **opts) # rubocop:disable Lint/UnusedMethodArgument
|
45
|
+
@connection_string = connection_string
|
46
46
|
@logger = logger
|
47
47
|
end
|
48
48
|
|
@@ -39,12 +39,11 @@ module GitLab
|
|
39
39
|
|
40
40
|
attr_reader :metrics, :collector, :bloat_types
|
41
41
|
|
42
|
-
def initialize(
|
43
|
-
|
44
|
-
|
45
|
-
logger: nil)
|
42
|
+
def initialize(metrics: PrometheusMetrics.new,
|
43
|
+
logger: nil,
|
44
|
+
**opts)
|
46
45
|
@metrics = metrics
|
47
|
-
@collector = collector
|
46
|
+
@collector = opts[:collector] || BloatCollector.new(**opts)
|
48
47
|
@collector.logger = logger
|
49
48
|
@bloat_types = opts[:bloat_types] || %i[btree table]
|
50
49
|
end
|
@@ -168,8 +168,8 @@ module GitLab
|
|
168
168
|
|
169
169
|
DEFAULT_UNARCHIVED_TRACES_OFFSET_MINUTES = 1440
|
170
170
|
|
171
|
-
def initialize(opts
|
172
|
-
super
|
171
|
+
def initialize(**opts)
|
172
|
+
super
|
173
173
|
|
174
174
|
@created_builds_counting_disabled = opts[:created_builds_counting_disabled]
|
175
175
|
@unarchived_traces_offset_minutes = opts[:unarchived_traces_offset_minutes]
|
@@ -294,13 +294,9 @@ module GitLab
|
|
294
294
|
|
295
295
|
# The prober which is called when gathering metrics
|
296
296
|
class CiBuildsProber
|
297
|
-
def initialize(
|
297
|
+
def initialize(metrics: PrometheusMetrics.new, **opts)
|
298
298
|
@metrics = metrics
|
299
|
-
|
300
|
-
collector_opts = { connection_string: opts[:connection_string],
|
301
|
-
created_builds_counting_disabled: opts[:created_builds_counting_disabled],
|
302
|
-
unarchived_traces_offset_minutes: opts[:unarchived_traces_offset_minutes] }
|
303
|
-
@collector = CiBuildsCollector.new(collector_opts, logger: logger)
|
299
|
+
@collector = CiBuildsCollector.new(**opts)
|
304
300
|
end
|
305
301
|
|
306
302
|
def probe_db
|
@@ -391,7 +387,7 @@ module GitLab
|
|
391
387
|
labels[:namespace] = "" unless labels[:namespace]
|
392
388
|
|
393
389
|
selected_labels = labels.select { |k, _| allowed_labels.include?(k) }.sort.to_h
|
394
|
-
@metrics.add(metric_name, value.to_f, selected_labels)
|
390
|
+
@metrics.add(metric_name, value.to_f, **selected_labels)
|
395
391
|
end
|
396
392
|
|
397
393
|
def unarchived_traces_metrics
|
@@ -10,8 +10,8 @@ module GitLab
|
|
10
10
|
FROM remote_mirrors WHERE project_id IN (%s) AND enabled = 't'
|
11
11
|
SQL
|
12
12
|
|
13
|
-
def initialize(args)
|
14
|
-
super(args)
|
13
|
+
def initialize(**args)
|
14
|
+
super(**args)
|
15
15
|
|
16
16
|
@project_ids = args[:project_ids]
|
17
17
|
end
|
@@ -35,7 +35,7 @@ module GitLab
|
|
35
35
|
|
36
36
|
# The prober which is called when gathering metrics
|
37
37
|
class RemoteMirrorsProber
|
38
|
-
def initialize(
|
38
|
+
def initialize(metrics: PrometheusMetrics.new, **opts)
|
39
39
|
@metrics = metrics
|
40
40
|
@collector = RemoteMirrorsCollector.new(
|
41
41
|
connection_string: opts[:connection_string],
|
@@ -131,13 +131,29 @@ module GitLab
|
|
131
131
|
visibility_level: {},
|
132
132
|
root: { definition: "(parent_id IS NULL)" }
|
133
133
|
}
|
134
|
-
}
|
134
|
+
},
|
135
|
+
registry_gc_manifest_review_queue: { select: :gc_manifest_review_queue },
|
136
|
+
registry_gc_manifest_review_queue_overdue: {
|
137
|
+
select: :gc_manifest_review_queue,
|
138
|
+
where: "review_after < NOW()"
|
139
|
+
},
|
140
|
+
registry_gc_blob_review_queue: { select: :gc_blob_review_queue },
|
141
|
+
registry_gc_blob_review_queue_overdue: {
|
142
|
+
select: :gc_blob_review_queue,
|
143
|
+
where: "review_after < NOW()"
|
144
|
+
},
|
145
|
+
registry_top_level_namespaces: { select: :top_level_namespaces },
|
146
|
+
# Please note that the tables below are partitioned, so a SELECT COUNT(*)
|
147
|
+
# will scale poorly. Avoid using these in production:
|
148
|
+
registry_repositories: { select: :repositories },
|
149
|
+
registry_manifests: { select: :manifests },
|
150
|
+
registry_blobs: { select: :blobs }
|
135
151
|
}.freeze
|
136
152
|
|
137
|
-
def initialize(args)
|
138
|
-
super(args)
|
153
|
+
def initialize(selected_queries: nil, **args)
|
154
|
+
super(**args)
|
139
155
|
|
140
|
-
@selected_queries = Set.new(
|
156
|
+
@selected_queries = Set.new(selected_queries.map(&:to_sym)) unless selected_queries.nil?
|
141
157
|
end
|
142
158
|
|
143
159
|
def run
|
@@ -200,12 +216,9 @@ module GitLab
|
|
200
216
|
|
201
217
|
# The prober which is called when gathering metrics
|
202
218
|
class RowCountProber
|
203
|
-
def initialize(
|
219
|
+
def initialize(metrics: PrometheusMetrics.new, **opts)
|
204
220
|
@metrics = metrics
|
205
|
-
@collector = RowCountCollector.new(
|
206
|
-
connection_string: opts[:connection_string],
|
207
|
-
selected_queries: opts[:selected_queries]
|
208
|
-
)
|
221
|
+
@collector = RowCountCollector.new(**opts)
|
209
222
|
end
|
210
223
|
|
211
224
|
def probe_db
|
@@ -25,9 +25,9 @@ module GitLab
|
|
25
25
|
|
26
26
|
# Probes the DB specified by opts[:connection_string] for tuple stats, then converts them to metrics
|
27
27
|
class TuplesProber
|
28
|
-
def initialize(
|
28
|
+
def initialize(metrics: PrometheusMetrics.new, **opts)
|
29
29
|
@metrics = metrics
|
30
|
-
@collector = TupleStatsCollector.new(
|
30
|
+
@collector = TupleStatsCollector.new(**opts)
|
31
31
|
end
|
32
32
|
|
33
33
|
def probe_db
|
data/lib/gitlab_exporter/git.rb
CHANGED
@@ -64,10 +64,10 @@ module GitLab
|
|
64
64
|
# Optionally takes a metrics object which by default is a PrometheusMetrics, useful to change the
|
65
65
|
# metrics writer to something else.
|
66
66
|
class GitProber
|
67
|
-
def initialize(
|
67
|
+
def initialize(source:, metrics: PrometheusMetrics.new, labels: {}, **opts) # rubocop:disable Lint/UnusedMethodArgument
|
68
68
|
@metrics = metrics
|
69
|
-
@labels =
|
70
|
-
@git = Git.new(
|
69
|
+
@labels = labels
|
70
|
+
@git = Git.new(source)
|
71
71
|
end
|
72
72
|
|
73
73
|
def probe_pull
|
@@ -87,9 +87,9 @@ module GitLab
|
|
87
87
|
|
88
88
|
# A special prober for git processes
|
89
89
|
class GitProcessProber
|
90
|
-
def initialize(
|
91
|
-
@opts = opts
|
90
|
+
def initialize(metrics: PrometheusMetrics.new, quantiles: nil, **opts) # rubocop:disable Lint/UnusedMethodArgument
|
92
91
|
@metrics = metrics
|
92
|
+
@quantiles = quantiles
|
93
93
|
end
|
94
94
|
|
95
95
|
def probe_git # rubocop:disable Metrics/MethodLength
|
@@ -115,7 +115,7 @@ module GitLab
|
|
115
115
|
{
|
116
116
|
name: name,
|
117
117
|
pid_or_pattern: pid,
|
118
|
-
quantiles: @
|
118
|
+
quantiles: @quantiles
|
119
119
|
},
|
120
120
|
metrics: @metrics
|
121
121
|
)
|
@@ -2,7 +2,7 @@ module GitLab
|
|
2
2
|
module Exporter
|
3
3
|
# A class to combine multiple probers into one
|
4
4
|
class Prober
|
5
|
-
def initialize(
|
5
|
+
def initialize(metrics: PrometheusMetrics.new, logger: nil, **prober_opts)
|
6
6
|
@prober_opts = prober_opts
|
7
7
|
@metrics = metrics
|
8
8
|
@logger = logger
|
@@ -13,7 +13,7 @@ module GitLab
|
|
13
13
|
def probe_all
|
14
14
|
@prober_opts.each do |_probe_name, params|
|
15
15
|
Utils.wrap_in_array(params[:opts]).each do |opts|
|
16
|
-
prober = params[:class].new(
|
16
|
+
prober = params[:class].new(metrics: @metrics, logger: @logger, **opts)
|
17
17
|
params[:methods].each do |meth|
|
18
18
|
prober.send(meth)
|
19
19
|
end
|
@@ -59,15 +59,15 @@ module GitLab
|
|
59
59
|
|
60
60
|
# Probes a process for info then writes metrics to a target
|
61
61
|
class ProcessProber
|
62
|
-
def initialize(
|
62
|
+
def initialize(name:, metrics: PrometheusMetrics.new, quantiles: false, **options)
|
63
63
|
@metrics = metrics
|
64
|
-
@name =
|
64
|
+
@name = name
|
65
65
|
@pids = if options[:pid_or_pattern] =~ /^\d+$/
|
66
66
|
[options[:pid_or_pattern]]
|
67
67
|
else
|
68
68
|
Utils.pgrep(options[:pid_or_pattern])
|
69
69
|
end
|
70
|
-
@use_quantiles =
|
70
|
+
@use_quantiles = quantiles
|
71
71
|
end
|
72
72
|
|
73
73
|
def probe_stat
|
data/lib/gitlab_exporter/ruby.rb
CHANGED
@@ -4,9 +4,9 @@ module GitLab
|
|
4
4
|
module Exporter
|
5
5
|
# Probes a current process GC for info then writes metrics to a target
|
6
6
|
class RubyProber
|
7
|
-
def initialize(
|
7
|
+
def initialize(metrics: PrometheusMetrics.new, quantiles: false, **opts) # rubocop:disable Lint/UnusedMethodArgument
|
8
8
|
@metrics = metrics
|
9
|
-
@use_quantiles =
|
9
|
+
@use_quantiles = quantiles
|
10
10
|
end
|
11
11
|
|
12
12
|
def probe_gc
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "sidekiq/api"
|
2
|
+
require "sidekiq/scheduled"
|
2
3
|
require "digest"
|
3
4
|
|
4
5
|
module GitLab
|
@@ -32,7 +33,7 @@ module GitLab
|
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
|
-
def initialize(
|
36
|
+
def initialize(metrics: PrometheusMetrics.new, logger: nil, **opts)
|
36
37
|
@opts = opts
|
37
38
|
@metrics = metrics
|
38
39
|
@logger = logger
|
@@ -76,6 +77,27 @@ module GitLab
|
|
76
77
|
self
|
77
78
|
end
|
78
79
|
|
80
|
+
def probe_future_sets
|
81
|
+
now = Time.now.to_f
|
82
|
+
with_sidekiq do
|
83
|
+
Sidekiq.redis do |conn|
|
84
|
+
Sidekiq::Scheduled::SETS.each do |set|
|
85
|
+
# Default to 0; if all jobs are due in the future, there is no "negative" delay.
|
86
|
+
delay = 0
|
87
|
+
|
88
|
+
_job, timestamp = conn.zrangebyscore(set, "-inf", now.to_s, limit: [0, 1], withscores: true).first
|
89
|
+
delay = now - timestamp if timestamp
|
90
|
+
|
91
|
+
@metrics.add("sidekiq_#{set}_set_processing_delay_seconds", delay)
|
92
|
+
|
93
|
+
# zcount is O(log(N)) (prob. binary search), so is still quick even with large sets
|
94
|
+
@metrics.add("sidekiq_#{set}_set_backlog_count",
|
95
|
+
conn.zcount(set, "-inf", now.to_s))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
79
101
|
# Count worker classes present in Sidekiq queues. This only looks at the
|
80
102
|
# first PROBE_JOBS_LIMIT jobs in each queue. This means that we run a
|
81
103
|
# single LRANGE command for each queue, which does not block other
|
@@ -89,7 +89,7 @@ module GitLab
|
|
89
89
|
|
90
90
|
get "/#{probe_name}" do
|
91
91
|
content_type "text/plain; version=0.0.4"
|
92
|
-
prober = Prober.new(
|
92
|
+
prober = Prober.new(metrics: PrometheusMetrics.new(include_timestamp: false), logger: logger, **opts)
|
93
93
|
|
94
94
|
prober.probe_all
|
95
95
|
prober.write_to(response)
|
data/spec/database/bloat_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe GitLab::Exporter::Database::BloatCollector do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
describe GitLab::Exporter::Database::BloatProber do
|
29
|
-
let(:opts) { { bloat_types: %i[btree table] } }
|
29
|
+
let(:opts) { { bloat_types: %i[btree table], connection_string: "" } }
|
30
30
|
let(:metrics) { double("PrometheusMetrics", add: nil) }
|
31
31
|
let(:collector) { double("BloatCollector", run: data) }
|
32
32
|
|
@@ -43,7 +43,7 @@ describe GitLab::Exporter::Database::BloatProber do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "#probe_db" do
|
46
|
-
subject { described_class.new(
|
46
|
+
subject { described_class.new(metrics: metrics, collector: collector, logger: STDOUT, **opts).probe_db }
|
47
47
|
|
48
48
|
before do
|
49
49
|
expect(collector).to receive(:logger=).with(STDOUT)
|
@@ -92,7 +92,7 @@ describe GitLab::Exporter::Database::BloatProber do
|
|
92
92
|
describe "#write_to" do
|
93
93
|
let(:target) { double }
|
94
94
|
let(:metrics) { double("PrometheusMetrics", to_s: double) }
|
95
|
-
subject { described_class.new(
|
95
|
+
subject { described_class.new(metrics: metrics, **opts).write_to(target) }
|
96
96
|
|
97
97
|
it "writes to given target" do
|
98
98
|
expect(target).to receive(:write).with(metrics.to_s)
|
@@ -216,11 +216,12 @@ describe GitLab::Exporter::Database do
|
|
216
216
|
describe GitLab::Exporter::Database::CiBuildsProber do
|
217
217
|
let(:writer) { StringIO.new }
|
218
218
|
let(:prober) do
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
219
|
+
described_class.new(
|
220
|
+
connection_string: "host=localhost",
|
221
|
+
created_builds_counting_disabled: created_builds_counting_disabled,
|
222
|
+
unarchived_traces_offset_minutes: unarchived_traces_offset_minutes,
|
223
|
+
metrics: GitLab::Exporter::PrometheusMetrics.new(include_timestamp: false)
|
224
|
+
)
|
224
225
|
end
|
225
226
|
|
226
227
|
before do
|
data/spec/git_spec.rb
CHANGED
@@ -34,17 +34,17 @@ context "With valid pair of repositories" do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
describe GitLab::Exporter::GitProber do
|
37
|
-
let(:options) {
|
37
|
+
let(:options) { { source: repos.cloned_repo, labels: {} } }
|
38
38
|
let(:output) { StringIO.new }
|
39
39
|
|
40
40
|
it "probes and monitors a pull" do
|
41
|
-
prober = GitLab::Exporter::GitProber.new(options)
|
41
|
+
prober = GitLab::Exporter::GitProber.new(**options)
|
42
42
|
prober.probe_pull.write_to(output)
|
43
43
|
expect(output.string).to match(/git_pull_time_milliseconds \d+ \d+/)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "probes and monitors a push" do
|
47
|
-
prober = GitLab::Exporter::GitProber.new(options)
|
47
|
+
prober = GitLab::Exporter::GitProber.new(**options)
|
48
48
|
prober.probe_push.write_to(output)
|
49
49
|
expect(output.string).to match(/git_push_time_milliseconds \d+ \d+/)
|
50
50
|
end
|
data/spec/ruby_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
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: 11.0
|
4
|
+
version: 11.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Carranza
|
@@ -112,16 +112,16 @@ dependencies:
|
|
112
112
|
name: sinatra
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.0
|
117
|
+
version: 2.1.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 2.0
|
124
|
+
version: 2.1.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|