gitlab-exporter 10.0.0 → 10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f7115d7a7e8604d15ad7734afd3280c22edf9f6911af159f9386f2a9d495701
4
- data.tar.gz: 7b050b23851b8073da229a5347b0c22afd641a1420859f37f0a0b8a7a4113244
3
+ metadata.gz: 93717aa36fc361dbf6e6550ffd1aee5bb4c36fd70f46c9688ee86dcdc94f7572
4
+ data.tar.gz: 7e97447aee55e492879c51d6740f1d73b959b235c09d59a3cca7d9595bc1669b
5
5
  SHA512:
6
- metadata.gz: 848007d860313f8d62239b3f97a9024944aec9ddbfe6ea97472eaae64ddfc6e03cc056fe9466ce719209a6fad2b5a88947ff085f25ed6cf4ecf6421c1db576d7
7
- data.tar.gz: f751e8af1eea6d30eb00dae65ec41681b50e9481a392b6521fde15c07934d8550dd2c3e3b65ea13ae6cbc0adadfe30986bad418c88172699b3172d20f9f62a75
6
+ metadata.gz: ca6b7c6192be12153b5392dd1fa4526c247bae7a8dfcf28f03ab262039a1abf29c27b40a8e0cb7efe3d6eb156bd4f472645307d53407ed87058fb3c5fd3013dd
7
+ data.tar.gz: 6a9125c7d46223b178bbc3d180482fd4f44643e02bc7b5887a3a264597cfa25a5cf5c6bc0782b79969dc89c09f34140b2aea47f8d6530d6ef48f301650218101
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-exporter (10.0.0)
4
+ gitlab-exporter (10.1.0)
5
5
  connection_pool (~> 2.2.1)
6
6
  pg (~> 1.1)
7
7
  puma (~> 5.1.1)
@@ -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.4)
22
+ nio4r (2.5.7)
23
23
  parallel (1.20.1)
24
24
  parser (3.0.0.0)
25
25
  ast (~> 2.4.1)
data/README.md CHANGED
@@ -33,23 +33,6 @@ metrics.
33
33
  * [git pull/push timings](lib/gitlab_exporter/git.rb) --
34
34
  `git_pull_time_milliseconds`, `git_push_time_milliseconds`
35
35
  * git processes stats (see Process below)
36
- 1. [Process](lib/gitlab_exporter/process.rb)
37
- * CPU time -- `process_cpu_seconds_total`
38
- * Start time -- `process_start_time_seconds`
39
- * Count -- `process_count`
40
- * Memory usage
41
- * Data from /proc/<pid>/cmdline:
42
- * `process_resident_memory_bytes`
43
- * `process_virtual_memory_bytes`
44
- * Data from /proc/<pid>/smaps -- `probe_smaps` (off by default):
45
- * `process_smaps_size_bytes`
46
- * `process_smaps_rss_bytes`
47
- * `process_smaps_shared_clean_bytes`
48
- * `process_smaps_shared_dirty_bytes`
49
- * `process_smaps_private_clean_bytes`
50
- * `process_smaps_private_dirty_bytes`
51
- * `process_smaps_swap_bytes`
52
- * `process_smaps_pss_bytes`
53
36
  1. [Sidekiq](lib/gitlab_exporter/sidekiq.rb)
54
37
  * Stats
55
38
  * `sidekiq_jobs_processed_total`
@@ -46,7 +46,6 @@ probes:
46
46
  <<: *db_common
47
47
  opts:
48
48
  <<: *db_common_opts
49
- allowed_repeated_commands_count: 2
50
49
  created_builds_counting_disabled: true
51
50
  unarchived_traces_offset_minutes: 1440
52
51
  tuple_stats:
@@ -147,100 +147,6 @@ module GitLab
147
147
  SELECT COUNT(*) FROM licenses
148
148
  SQL
149
149
 
150
- REPEATED_COMMANDS_QUERY_EE =
151
- <<~SQL.freeze
152
- SELECT
153
- subquery.namespace_id,
154
- subquery.shared_runners_enabled,
155
- subquery.project_id,
156
- subquery.status,
157
- subquery.has_minutes,
158
- MAX(subquery.count) as count
159
- FROM (
160
- SELECT
161
- projects.namespace_id,
162
- projects.shared_runners_enabled,
163
- ci_builds.project_id,
164
- ci_builds.commit_id,
165
- ci_builds.status,
166
- (COALESCE(namespaces.shared_runners_minutes_limit, application_settings.shared_runners_minutes, 0) = 0 OR
167
- COALESCE(namespace_statistics.shared_runners_seconds, 0) < COALESCE(namespaces.shared_runners_minutes_limit, application_settings.shared_runners_minutes, 0) * 60) as has_minutes,
168
- COUNT(*) AS count
169
- FROM ci_builds
170
- JOIN projects
171
- ON projects.id = ci_builds.project_id
172
- JOIN namespaces
173
- ON namespaces.id = projects.namespace_id
174
- LEFT JOIN namespace_statistics
175
- ON namespace_statistics.namespace_id = namespaces.id
176
- JOIN application_settings ON (TRUE)
177
- WHERE ci_builds.type = 'Ci::Build'
178
- AND ci_builds.status IN ('running', 'pending')
179
- -- The created_at filter has been introduced for performance reasons only
180
- AND ci_builds.created_at > NOW() - INTERVAL '7 days'
181
- GROUP BY
182
- projects.namespace_id,
183
- projects.shared_runners_enabled,
184
- ci_builds.project_id,
185
- ci_builds.commit_id,
186
- ci_builds.status,
187
- ci_builds.commands,
188
- namespaces.shared_runners_minutes_limit,
189
- namespace_statistics.shared_runners_seconds,
190
- application_settings.shared_runners_minutes
191
- HAVING COUNT(*) > %d
192
- ) AS subquery
193
- GROUP BY
194
- subquery.namespace_id,
195
- subquery.shared_runners_enabled,
196
- subquery.project_id,
197
- subquery.commit_id,
198
- subquery.status,
199
- subquery.has_minutes
200
- SQL
201
-
202
- REPEATED_COMMANDS_QUERY_CE =
203
- <<~SQL.freeze
204
- SELECT
205
- subquery.namespace_id,
206
- subquery.shared_runners_enabled,
207
- subquery.project_id,
208
- subquery.status,
209
- MAX(subquery.count) as count
210
- FROM (
211
- SELECT
212
- projects.namespace_id,
213
- projects.shared_runners_enabled,
214
- ci_builds.project_id,
215
- ci_builds.commit_id,
216
- ci_builds.status,
217
- COUNT(*) AS count
218
- FROM ci_builds
219
- JOIN projects
220
- ON projects.id = ci_builds.project_id
221
- JOIN namespaces
222
- ON namespaces.id = projects.namespace_id
223
- WHERE ci_builds.type = 'Ci::Build'
224
- AND ci_builds.status IN ('running', 'pending')
225
- -- The created_at filter has been introduced for performance reasons only
226
- AND ci_builds.created_at > NOW() - INTERVAL '7 days'
227
- GROUP BY
228
- projects.namespace_id,
229
- projects.shared_runners_enabled,
230
- ci_builds.project_id,
231
- ci_builds.commit_id,
232
- ci_builds.status,
233
- ci_builds.commands
234
- HAVING COUNT(*) > %d
235
- ) AS subquery
236
- GROUP BY
237
- subquery.namespace_id,
238
- subquery.shared_runners_enabled,
239
- subquery.project_id,
240
- subquery.commit_id,
241
- subquery.status
242
- SQL
243
-
244
150
  UNARCHIVED_TRACES_QUERY =
245
151
  <<~SQL.freeze
246
152
  SELECT
@@ -265,7 +171,6 @@ module GitLab
265
171
  def initialize(opts, logger: nil)
266
172
  super(opts, logger: logger)
267
173
 
268
- @allowed_repeated_commands_count = opts[:allowed_repeated_commands_count]
269
174
  @created_builds_counting_disabled = opts[:created_builds_counting_disabled]
270
175
  @unarchived_traces_offset_minutes = opts[:unarchived_traces_offset_minutes]
271
176
  end
@@ -276,7 +181,6 @@ module GitLab
276
181
  results[:pending_builds] = builds(STATUS_PENDING)
277
182
  results[:stale_builds] = stale_builds
278
183
  results[:per_runner] = per_runner_builds
279
- results[:repeated_commands] = repeated_commands
280
184
  results[:unarchived_traces] = unarchived_traces
281
185
  results
282
186
  end
@@ -335,34 +239,6 @@ module GitLab
335
239
  include_ee_fields(values, row)
336
240
  end
337
241
 
338
- def repeated_commands
339
- results = []
340
-
341
- query = ee? ? REPEATED_COMMANDS_QUERY_EE : REPEATED_COMMANDS_QUERY_CE
342
- query = query % [allowed_repeated_commands_count] # rubocop:disable Style/FormatString
343
- exec_query_with_custom_random_page_cost(query).each do |row|
344
- results << transform_repeated_commands_row_to_values(row)
345
- end
346
-
347
- results
348
- rescue PG::UndefinedTable, PG::UndefinedColumn
349
- []
350
- end
351
-
352
- def allowed_repeated_commands_count
353
- @allowed_repeated_commands_count ||= 2
354
- end
355
-
356
- def transform_repeated_commands_row_to_values(row)
357
- values = { namespace: row["namespace_id"].to_s,
358
- project: row["project_id"].to_s,
359
- shared_runners: row["shared_runners_enabled"] == "t" ? "yes" : "no",
360
- status: row["status"].to_s,
361
- value: row["count"].to_i }
362
-
363
- include_has_minutes_field(values, row)
364
- end
365
-
366
242
  def unarchived_traces
367
243
  time = Time.now - (unarchived_traces_offset_minutes * 60)
368
244
  query = UNARCHIVED_TRACES_QUERY % [time.strftime("%F %T")] # rubocop:disable Style/FormatString
@@ -422,7 +298,6 @@ module GitLab
422
298
  @metrics = metrics
423
299
 
424
300
  collector_opts = { connection_string: opts[:connection_string],
425
- allowed_repeated_commands_count: opts[:allowed_repeated_commands_count],
426
301
  created_builds_counting_disabled: opts[:created_builds_counting_disabled],
427
302
  unarchived_traces_offset_minutes: opts[:unarchived_traces_offset_minutes] }
428
303
  @collector = CiBuildsCollector.new(collector_opts, logger: logger)
@@ -435,7 +310,6 @@ module GitLab
435
310
  ci_builds_metrics(@results[:pending_builds], "ci_pending_builds")
436
311
  ci_stale_builds_metrics
437
312
  metrics_per_runner
438
- repeated_commands_metrics
439
313
  unarchived_traces_metrics
440
314
 
441
315
  self
@@ -520,14 +394,6 @@ module GitLab
520
394
  @metrics.add(metric_name, value.to_f, selected_labels)
521
395
  end
522
396
 
523
- def repeated_commands_metrics
524
- @results[:repeated_commands].each do |metric|
525
- value = metric.delete(:value)
526
-
527
- @metrics.add("ci_repeated_commands_builds", value.to_f, metric)
528
- end
529
- end
530
-
531
397
  def unarchived_traces_metrics
532
398
  @metrics.add("ci_unarchived_traces", @results[:unarchived_traces].to_f)
533
399
  end
@@ -1,5 +1,5 @@
1
1
  module GitLab
2
2
  module Exporter
3
- VERSION = "10.0.0".freeze
3
+ VERSION = "10.1.0".freeze
4
4
  end
5
5
  end
@@ -10,12 +10,9 @@ describe GitLab::Exporter::Database do
10
10
  let(:per_runner_query_ee) { "SELECT ALL RUNNING PER RUNNER EE" }
11
11
  let(:per_runner_query_ce) { "SELECT ALL RUNNING PER RUNNER CE" }
12
12
  let(:ee_check_query) { "SELECT COUNT(*) FROM licenses" }
13
- let(:repeated_commands_query_ee) { "SELECT EE REPEATED COMNANDS %d" }
14
- let(:repeated_commands_query_ce) { "SELECT CE REPEATED COMNANDS %d" }
15
13
  let(:unarchived_traces_query) { "SELECT UNARCHIVED TRACES %s LIST" }
16
14
  let(:connection_pool) { double("connection pool") }
17
15
  let(:connection) { double("connection") }
18
- let(:allowed_repeated_commands_count) { 5 }
19
16
  let(:created_builds_counting_disabled) { true }
20
17
  let(:time_now) { Time.new(2019, 4, 9, 6, 30, 0) }
21
18
  let(:unarchived_traces_query_time) { "2019-04-09 05:30:00" }
@@ -63,22 +60,6 @@ describe GitLab::Exporter::Database do
63
60
  end
64
61
  # rubocop:enable Metrics/ParameterLists
65
62
 
66
- # rubocop:disable Metrics/ParameterLists
67
- def repeated_commands_query_row_ee(namespace_id, shared_runners_enabled, project_id, status, has_minutes, count)
68
- row = repeated_commands_query_row_ce(namespace_id, shared_runners_enabled, project_id, status, count)
69
- row["has_minutes"] = has_minutes
70
- row
71
- end
72
- # rubocop:enable Metrics/ParameterLists
73
-
74
- def repeated_commands_query_row_ce(namespace_id, shared_runners_enabled, project_id, status, count)
75
- { "namespace_id" => namespace_id,
76
- "shared_runners_enabled" => shared_runners_enabled,
77
- "project_id" => project_id,
78
- "status" => status,
79
- "count" => count }
80
- end
81
-
82
63
  before do
83
64
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::SET_RANDOM_PAGE_COST", set_random_page_cost_query)
84
65
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::BUILDS_QUERY_EE", builds_query_ee)
@@ -87,8 +68,6 @@ describe GitLab::Exporter::Database do
87
68
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::PER_RUNNER_QUERY_EE", per_runner_query_ee)
88
69
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::PER_RUNNER_QUERY_CE", per_runner_query_ce)
89
70
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::EE_CHECK_QUERY", ee_check_query)
90
- stub_const("GitLab::Exporter::Database::CiBuildsCollector::REPEATED_COMMANDS_QUERY_EE", repeated_commands_query_ee)
91
- stub_const("GitLab::Exporter::Database::CiBuildsCollector::REPEATED_COMMANDS_QUERY_CE", repeated_commands_query_ce)
92
71
  stub_const("GitLab::Exporter::Database::CiBuildsCollector::UNARCHIVED_TRACES_QUERY", unarchived_traces_query)
93
72
 
94
73
  allow_any_instance_of(GitLab::Exporter::Database::CiBuildsCollector).to receive(:connection_pool).and_return(connection_pool)
@@ -130,24 +109,6 @@ describe GitLab::Exporter::Database do
130
109
  per_runner_query_row_ce(2, "project_type", 3, nil, 3, 5),
131
110
  per_runner_query_row_ce(3, "project_type", 4, nil, 3, 5)])
132
111
 
133
- # rubocop:disable Style/FormatString
134
- repeated_commands_query_ee_with_limit = repeated_commands_query_ee % [allowed_repeated_commands_count]
135
- repeated_commands_query_ce_with_limit = repeated_commands_query_ce % [allowed_repeated_commands_count]
136
- # rubocop:enable Style/FormatString
137
-
138
- allow(connection).to receive(:exec)
139
- .with(repeated_commands_query_ee_with_limit)
140
- .and_return([repeated_commands_query_row_ee(1, "t", 1, "pending", "t", 10),
141
- repeated_commands_query_row_ee(2, "f", 2, "running", "f", 20),
142
- repeated_commands_query_row_ee(1, "f", 3, "pending", "t", 30),
143
- repeated_commands_query_row_ee(2, "t", 4, "running", "f", 40)])
144
- allow(connection).to receive(:exec)
145
- .with(repeated_commands_query_ce_with_limit)
146
- .and_return([repeated_commands_query_row_ce(1, "t", 1, "pending", 10),
147
- repeated_commands_query_row_ce(2, "f", 2, "running", 20),
148
- repeated_commands_query_row_ce(1, "f", 3, "pending", 30),
149
- repeated_commands_query_row_ce(2, "t", 4, "running", 40)])
150
-
151
112
  unarchived_traces_query_with_time = unarchived_traces_query % [unarchived_traces_query_time] # rubocop:disable Style/FormatString
152
113
 
153
114
  allow(connection).to receive(:exec).with(unarchived_traces_query_with_time).and_return([{ "count" => 10 }])
@@ -156,7 +117,6 @@ describe GitLab::Exporter::Database do
156
117
  describe GitLab::Exporter::Database::CiBuildsCollector do
157
118
  let(:collector) do
158
119
  described_class.new(connection_string: "host=localhost",
159
- allowed_repeated_commands_count: allowed_repeated_commands_count,
160
120
  created_builds_counting_disabled: created_builds_counting_disabled,
161
121
  unarchived_traces_offset_minutes: unarchived_traces_offset_minutes)
162
122
  end
@@ -195,10 +155,6 @@ describe GitLab::Exporter::Database do
195
155
  expect(subject[:stale_builds]).to eq(expected_stale_builds)
196
156
  end
197
157
 
198
- it "returns raw repeated_commands data" do
199
- expect(subject[:repeated_commands]).to include(*expected_repeated_commands)
200
- end
201
-
202
158
  it "returns raw unarchived_traces data" do
203
159
  expect(subject[:unarchived_traces]).to eq(expected_unarchived_traces)
204
160
  end
@@ -222,12 +178,6 @@ describe GitLab::Exporter::Database do
222
178
  { 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
179
  { 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
180
  end
225
- let(:expected_repeated_commands) do
226
- [{ namespace: "1", project: "1", shared_runners: "yes", status: "pending", has_minutes: "yes", value: 10.0 },
227
- { namespace: "2", project: "2", shared_runners: "no", status: "running", has_minutes: "no", value: 20.0 },
228
- { namespace: "1", project: "3", shared_runners: "no", status: "pending", has_minutes: "yes", value: 30.0 },
229
- { namespace: "2", project: "4", shared_runners: "yes", status: "running", has_minutes: "no", value: 40.0 }]
230
- end
231
181
 
232
182
  before do
233
183
  stub_ee
@@ -254,12 +204,6 @@ describe GitLab::Exporter::Database do
254
204
  { runner: "2", runner_type: "project_type", namespace: "3", scheduled: "no", triggered: "yes", value: 5 },
255
205
  { runner: "3", runner_type: "project_type", namespace: "4", scheduled: "no", triggered: "yes", value: 5 }]
256
206
  end
257
- let(:expected_repeated_commands) do
258
- [{ namespace: "1", project: "1", shared_runners: "yes", status: "pending", value: 10 },
259
- { namespace: "2", project: "2", shared_runners: "no", status: "running", value: 20 },
260
- { namespace: "1", project: "3", shared_runners: "no", status: "pending", value: 30 },
261
- { namespace: "2", project: "4", shared_runners: "yes", status: "running", value: 40 }]
262
- end
263
207
 
264
208
  before do
265
209
  stub_ce
@@ -273,7 +217,6 @@ describe GitLab::Exporter::Database do
273
217
  let(:writer) { StringIO.new }
274
218
  let(:prober) do
275
219
  opts = { connection_string: "host=localhost",
276
- allowed_repeated_commands_count: allowed_repeated_commands_count,
277
220
  created_builds_counting_disabled: created_builds_counting_disabled,
278
221
  unarchived_traces_offset_minutes: unarchived_traces_offset_minutes }
279
222
  described_class.new(opts,
@@ -324,12 +267,6 @@ describe GitLab::Exporter::Database do
324
267
  end
325
268
  end
326
269
 
327
- it "responds with repeated commands Prometheus metrics" do
328
- ci_repeated_commands_builds_lines.each do |expected_line|
329
- expect(subject).to match(Regexp.new("^#{expected_line}$", Regexp::MULTILINE))
330
- end
331
- end
332
-
333
270
  it "responds with stale builds Prometheus metrics" do
334
271
  expect(subject).to match(/^ci_stale_builds 2.0$/m)
335
272
  end
@@ -372,12 +309,6 @@ describe GitLab::Exporter::Database do
372
309
  '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
310
  '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
311
  end
375
- let(:ci_repeated_commands_builds_lines) do
376
- ['ci_repeated_commands_builds\{namespace="1",project="1",shared_runners="yes",status="pending",has_minutes="yes"\} 10.0',
377
- 'ci_repeated_commands_builds\{namespace="2",project="2",shared_runners="no",status="running",has_minutes="no"\} 20.0',
378
- 'ci_repeated_commands_builds\{namespace="1",project="3",shared_runners="no",status="pending",has_minutes="yes"\} 30.0',
379
- 'ci_repeated_commands_builds\{namespace="2",project="4",shared_runners="yes",status="running",has_minutes="no"\} 40.0']
380
- end
381
312
  let(:namespace_out_of_limit) { 2 }
382
313
 
383
314
  before do
@@ -403,12 +334,6 @@ describe GitLab::Exporter::Database do
403
334
  'ci_running_builds\{namespace="",runner="2",runner_type="project_type",scheduled="no",triggered="yes"\} 10.0',
404
335
  'ci_running_builds\{namespace="",runner="3",runner_type="project_type",scheduled="no",triggered="yes"\} 5.0']
405
336
  end
406
- let(:ci_repeated_commands_builds_lines) do
407
- ['ci_repeated_commands_builds\{namespace="1",project="1",shared_runners="yes",status="pending"\} 10.0',
408
- 'ci_repeated_commands_builds\{namespace="2",project="2",shared_runners="no",status="running"\} 20.0',
409
- 'ci_repeated_commands_builds\{namespace="1",project="3",shared_runners="no",status="pending"\} 30.0',
410
- 'ci_repeated_commands_builds\{namespace="2",project="4",shared_runners="yes",status="running"\} 40.0']
411
- end
412
337
  let(:namespace_out_of_limit) { 0 }
413
338
 
414
339
  before do
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: 10.0.0
4
+ version: 10.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Carranza