gitlab-exporter 5.2.2 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -7
- data/lib/gitlab_exporter/database/ci_builds.rb +7 -7
- data/lib/gitlab_exporter/version.rb +1 -1
- data/spec/database/ci_builds_spec.rb +27 -27
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1378d48a7af04eee678edaa21da6d5795baa5828d0b06853b816e8c6b8e8d489
|
4
|
+
data.tar.gz: e221a2070050abee80662777a94afee1d4369ae8f108583f28f640cc2fc2517b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7c222835cd8bc99f412f95fb17457310857634b4c9c9b9b2ffb3a1f5b7002b05445f6331f4e0cdd74a4319d4bf0730e68070acd043168b65d8bfacf52da1e88
|
7
|
+
data.tar.gz: e4d5aababedf60ee0865f5b9c455011f0941acb2d8ad0bb21bb6c4a2021aeba23ac3d2123238d8cc7932e70bc508dca43f3e396031b57b199c6aff752d86d457
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gitlab-exporter (
|
4
|
+
gitlab-exporter (6.0.0)
|
5
5
|
connection_pool (~> 2.2.1)
|
6
6
|
pg (~> 1.1)
|
7
7
|
quantile (~> 0.2.0)
|
@@ -16,14 +16,15 @@ GEM
|
|
16
16
|
ast (2.4.0)
|
17
17
|
connection_pool (2.2.2)
|
18
18
|
diff-lcs (1.3)
|
19
|
-
mustermann (1.
|
19
|
+
mustermann (1.1.1)
|
20
|
+
ruby2_keywords (~> 0.0.1)
|
20
21
|
parser (2.5.1.0)
|
21
22
|
ast (~> 2.4.0)
|
22
23
|
pg (1.2.2)
|
23
24
|
powerpack (0.1.1)
|
24
25
|
quantile (0.2.1)
|
25
|
-
rack (2.
|
26
|
-
rack-protection (2.0.
|
26
|
+
rack (2.1.2)
|
27
|
+
rack-protection (2.0.8.1)
|
27
28
|
rack
|
28
29
|
rainbow (2.1.0)
|
29
30
|
redis (4.1.3)
|
@@ -49,17 +50,18 @@ GEM
|
|
49
50
|
ruby-progressbar (~> 1.7)
|
50
51
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
51
52
|
ruby-progressbar (1.8.1)
|
53
|
+
ruby2_keywords (0.0.2)
|
52
54
|
sidekiq (5.2.7)
|
53
55
|
connection_pool (~> 2.2, >= 2.2.2)
|
54
56
|
rack (>= 1.5.0)
|
55
57
|
rack-protection (>= 1.5.0)
|
56
58
|
redis (>= 3.3.5, < 5)
|
57
|
-
sinatra (2.0.
|
59
|
+
sinatra (2.0.8.1)
|
58
60
|
mustermann (~> 1.0)
|
59
61
|
rack (~> 2.0)
|
60
|
-
rack-protection (= 2.0.
|
62
|
+
rack-protection (= 2.0.8.1)
|
61
63
|
tilt (~> 2.0)
|
62
|
-
tilt (2.0.
|
64
|
+
tilt (2.0.10)
|
63
65
|
unicode-display_width (1.6.0)
|
64
66
|
|
65
67
|
PLATFORMS
|
@@ -75,7 +75,7 @@ module GitLab
|
|
75
75
|
<<~SQL.freeze
|
76
76
|
SELECT
|
77
77
|
ci_builds.runner_id,
|
78
|
-
ci_runners.
|
78
|
+
ci_runners.runner_type,
|
79
79
|
projects.namespace_id,
|
80
80
|
projects.mirror,
|
81
81
|
projects.mirror_trigger_builds,
|
@@ -104,7 +104,7 @@ module GitLab
|
|
104
104
|
AND projects.pending_delete = 'f'
|
105
105
|
GROUP BY
|
106
106
|
ci_builds.runner_id,
|
107
|
-
ci_runners.
|
107
|
+
ci_runners.runner_type,
|
108
108
|
projects.namespace_id,
|
109
109
|
projects.mirror,
|
110
110
|
projects.mirror_trigger_builds,
|
@@ -119,7 +119,7 @@ module GitLab
|
|
119
119
|
<<~SQL.freeze
|
120
120
|
SELECT
|
121
121
|
ci_builds.runner_id,
|
122
|
-
ci_runners.
|
122
|
+
ci_runners.runner_type,
|
123
123
|
projects.namespace_id,
|
124
124
|
ci_pipelines.pipeline_schedule_id,
|
125
125
|
ci_builds.trigger_request_id,
|
@@ -138,7 +138,7 @@ module GitLab
|
|
138
138
|
AND projects.pending_delete = 'f'
|
139
139
|
GROUP BY
|
140
140
|
ci_builds.runner_id,
|
141
|
-
ci_runners.
|
141
|
+
ci_runners.runner_type,
|
142
142
|
projects.namespace_id,
|
143
143
|
ci_pipelines.pipeline_schedule_id,
|
144
144
|
ci_builds.trigger_request_id
|
@@ -330,7 +330,7 @@ module GitLab
|
|
330
330
|
|
331
331
|
def transform_per_runners_builds_row_to_values(row)
|
332
332
|
values = { runner: row["runner_id"].to_s,
|
333
|
-
|
333
|
+
runner_type: row["runner_type"],
|
334
334
|
namespace: row["namespace_id"].to_s,
|
335
335
|
scheduled: row["pipeline_schedule_id"] ? "yes" : "no",
|
336
336
|
triggered: row["trigger_request_id"] ? "yes" : "no",
|
@@ -488,7 +488,7 @@ module GitLab
|
|
488
488
|
@results[:per_runner].each do |metric|
|
489
489
|
# If we have a low value, put the value into an "other" bucket.
|
490
490
|
if metric[:value] < 10
|
491
|
-
key = { runner: metric[:runner],
|
491
|
+
key = { runner: metric[:runner], runner_type: metric[:runner_type],
|
492
492
|
scheduled: metric[:scheduled], triggered: metric[:triggered] }
|
493
493
|
key[:mirror] = metric[:mirror] if metric[:mirror]
|
494
494
|
key[:mirror_trigger_builds] = metric[:mirror_trigger_builds] if metric[:mirror_trigger_builds]
|
@@ -508,7 +508,7 @@ module GitLab
|
|
508
508
|
def add_ci_running_builds(value, labels)
|
509
509
|
add_metric_with_namespace_label(
|
510
510
|
"ci_running_builds",
|
511
|
-
[:runner, :namespace, :
|
511
|
+
[:runner, :namespace, :runner_type, :scheduled,
|
512
512
|
:triggered, :mirror, :mirror_trigger_builds, :has_minutes],
|
513
513
|
value,
|
514
514
|
labels
|
@@ -43,8 +43,8 @@ describe GitLab::Exporter::Database do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
# rubocop:disable Metrics/ParameterLists
|
46
|
-
def per_runner_query_row_ee(runner_id,
|
47
|
-
row = per_runner_query_row_ce(runner_id,
|
46
|
+
def per_runner_query_row_ee(runner_id, runner_type, namespace_id, mirror, mirror_trigger_builds, pipeline_schedule_id, trigger_request_id, has_minutes, count)
|
47
|
+
row = per_runner_query_row_ce(runner_id, runner_type, namespace_id, pipeline_schedule_id, trigger_request_id, count)
|
48
48
|
row["mirror"] = mirror
|
49
49
|
row["mirror_trigger_builds"] = mirror_trigger_builds
|
50
50
|
row["has_minutes"] = has_minutes
|
@@ -53,9 +53,9 @@ describe GitLab::Exporter::Database do
|
|
53
53
|
# rubocop:enable Metrics/ParameterLists
|
54
54
|
|
55
55
|
# rubocop:disable Metrics/ParameterLists
|
56
|
-
def per_runner_query_row_ce(runner_id,
|
56
|
+
def per_runner_query_row_ce(runner_id, runner_type, namespace_id, pipeline_schedule_id, trigger_request_id, count)
|
57
57
|
{ "runner_id" => runner_id,
|
58
|
-
"
|
58
|
+
"runner_type" => runner_type,
|
59
59
|
"namespace_id" => namespace_id,
|
60
60
|
"pipeline_schedule_id" => pipeline_schedule_id,
|
61
61
|
"trigger_request_id" => trigger_request_id,
|
@@ -119,16 +119,16 @@ describe GitLab::Exporter::Database do
|
|
119
119
|
allow(connection).to receive(:exec).with(stale_builds_query).and_return([{ "count" => 2 }])
|
120
120
|
|
121
121
|
allow(connection).to receive(:exec).with(per_runner_query_ee)
|
122
|
-
.and_return([per_runner_query_row_ee(1, "
|
123
|
-
per_runner_query_row_ee(2, "
|
124
|
-
per_runner_query_row_ee(2, "
|
125
|
-
per_runner_query_row_ee(3, "
|
122
|
+
.and_return([per_runner_query_row_ee(1, "instance_type", 1, "f", "f", 1, nil, "t", 15),
|
123
|
+
per_runner_query_row_ee(2, "project_type", 2, "t", "t", nil, 3, "f", 5),
|
124
|
+
per_runner_query_row_ee(2, "project_type", 3, "t", "t", nil, 3, "t", 5),
|
125
|
+
per_runner_query_row_ee(3, "project_type", 4, "t", "t", nil, 3, "f", 5)])
|
126
126
|
|
127
127
|
allow(connection).to receive(:exec).with(per_runner_query_ce)
|
128
|
-
.and_return([per_runner_query_row_ce(1, "
|
129
|
-
per_runner_query_row_ce(2, "
|
130
|
-
per_runner_query_row_ce(2, "
|
131
|
-
per_runner_query_row_ce(3, "
|
128
|
+
.and_return([per_runner_query_row_ce(1, "instance_type", 1, 1, nil, 15),
|
129
|
+
per_runner_query_row_ce(2, "project_type", 2, nil, 3, 5),
|
130
|
+
per_runner_query_row_ce(2, "project_type", 3, nil, 3, 5),
|
131
|
+
per_runner_query_row_ce(3, "project_type", 4, nil, 3, 5)])
|
132
132
|
|
133
133
|
# rubocop:disable Style/FormatString
|
134
134
|
repeated_commands_query_ee_with_limit = repeated_commands_query_ee % [allowed_repeated_commands_count]
|
@@ -217,10 +217,10 @@ describe GitLab::Exporter::Database do
|
|
217
217
|
{ namespace: "2", shared_runners: "no", has_minutes: "no", value: 20.0 }]
|
218
218
|
end
|
219
219
|
let(:expected_per_runner) do
|
220
|
-
[{ runner: "1",
|
221
|
-
{ runner: "2",
|
222
|
-
{ runner: "2",
|
223
|
-
{ runner: "3",
|
220
|
+
[{ runner: "1", runner_type: "instance_type", namespace: "1", mirror: "no", mirror_trigger_builds: "no", scheduled: "yes", triggered: "no", has_minutes: "yes", value: 15.0 },
|
221
|
+
{ runner: "2", runner_type: "project_type", namespace: "2", mirror: "yes", mirror_trigger_builds: "yes", scheduled: "no", triggered: "yes", has_minutes: "no", value: 5.0 },
|
222
|
+
{ runner: "2", runner_type: "project_type", namespace: "3", mirror: "yes", mirror_trigger_builds: "yes", scheduled: "no", triggered: "yes", has_minutes: "yes", value: 5.0 },
|
223
|
+
{ runner: "3", runner_type: "project_type", namespace: "4", mirror: "yes", mirror_trigger_builds: "yes", scheduled: "no", triggered: "yes", has_minutes: "no", value: 5.0 }]
|
224
224
|
end
|
225
225
|
let(:expected_repeated_commands) do
|
226
226
|
[{ namespace: "1", project: "1", shared_runners: "yes", status: "pending", has_minutes: "yes", value: 10.0 },
|
@@ -249,10 +249,10 @@ describe GitLab::Exporter::Database do
|
|
249
249
|
{ namespace: "2", shared_runners: "no", value: 20 }]
|
250
250
|
end
|
251
251
|
let(:expected_per_runner) do
|
252
|
-
[{ runner: "1",
|
253
|
-
{ runner: "2",
|
254
|
-
{ runner: "2",
|
255
|
-
{ runner: "3",
|
252
|
+
[{ runner: "1", runner_type: "instance_type", namespace: "1", scheduled: "yes", triggered: "no", value: 15 },
|
253
|
+
{ runner: "2", runner_type: "project_type", namespace: "2", scheduled: "no", triggered: "yes", value: 5 },
|
254
|
+
{ runner: "2", runner_type: "project_type", namespace: "3", scheduled: "no", triggered: "yes", value: 5 },
|
255
|
+
{ runner: "3", runner_type: "project_type", namespace: "4", scheduled: "no", triggered: "yes", value: 5 }]
|
256
256
|
end
|
257
257
|
let(:expected_repeated_commands) do
|
258
258
|
[{ namespace: "1", project: "1", shared_runners: "yes", status: "pending", value: 10 },
|
@@ -367,10 +367,10 @@ describe GitLab::Exporter::Database do
|
|
367
367
|
'ci_pending_builds\{has_minutes="no",namespace="",shared_runners="no"\} 2.0']
|
368
368
|
end
|
369
369
|
let(:ci_running_builds_expected_lines) do
|
370
|
-
['ci_running_builds\{has_minutes="yes",mirror="no",mirror_trigger_builds="no",namespace="1",runner="1",
|
371
|
-
'ci_running_builds\{has_minutes="no",mirror="yes",mirror_trigger_builds="yes",namespace="",runner="2",
|
372
|
-
'ci_running_builds\{has_minutes="yes",mirror="yes",mirror_trigger_builds="yes",namespace="",runner="2",
|
373
|
-
'ci_running_builds\{has_minutes="no",mirror="yes",mirror_trigger_builds="yes",namespace="",runner="3",
|
370
|
+
['ci_running_builds\{has_minutes="yes",mirror="no",mirror_trigger_builds="no",namespace="1",runner="1",runner_type="instance_type",scheduled="yes",triggered="no"\} 15.0',
|
371
|
+
'ci_running_builds\{has_minutes="no",mirror="yes",mirror_trigger_builds="yes",namespace="",runner="2",runner_type="project_type",scheduled="no",triggered="yes"\} 5.0',
|
372
|
+
'ci_running_builds\{has_minutes="yes",mirror="yes",mirror_trigger_builds="yes",namespace="",runner="2",runner_type="project_type",scheduled="no",triggered="yes"\} 5.0',
|
373
|
+
'ci_running_builds\{has_minutes="no",mirror="yes",mirror_trigger_builds="yes",namespace="",runner="3",runner_type="project_type",scheduled="no",triggered="yes"\} 5.0']
|
374
374
|
end
|
375
375
|
let(:ci_repeated_commands_builds_lines) do
|
376
376
|
['ci_repeated_commands_builds\{namespace="1",project="1",shared_runners="yes",status="pending",has_minutes="yes"\} 10.0',
|
@@ -399,9 +399,9 @@ describe GitLab::Exporter::Database do
|
|
399
399
|
'ci_pending_builds\{namespace="",shared_runners="no"\} 2.0']
|
400
400
|
end
|
401
401
|
let(:ci_running_builds_expected_lines) do
|
402
|
-
['ci_running_builds\{namespace="1",runner="1",
|
403
|
-
'ci_running_builds\{namespace="",runner="2",
|
404
|
-
'ci_running_builds\{namespace="",runner="3",
|
402
|
+
['ci_running_builds\{namespace="1",runner="1",runner_type="instance_type",scheduled="yes",triggered="no"\} 15.0',
|
403
|
+
'ci_running_builds\{namespace="",runner="2",runner_type="project_type",scheduled="no",triggered="yes"\} 10.0',
|
404
|
+
'ci_running_builds\{namespace="",runner="3",runner_type="project_type",scheduled="no",triggered="yes"\} 5.0']
|
405
405
|
end
|
406
406
|
let(:ci_repeated_commands_builds_lines) do
|
407
407
|
['ci_repeated_commands_builds\{namespace="1",project="1",shared_runners="yes",status="pending"\} 10.0',
|