gitlab-exporter 16.4.0 → 16.6.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 +8 -8
- data/gitlab-exporter.gemspec +1 -1
- data/lib/gitlab_exporter/database/zoekt.rb +229 -25
- data/lib/gitlab_exporter/version.rb +1 -1
- data/spec/database/zoekt_spec.rb +163 -10
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 741207042e803e24cf2a73e9c622606dc6814a7f335a1e512940977afac6d049
|
|
4
|
+
data.tar.gz: 27e0ec1192f33b5835e61ddd2a86df4c131673f2c46b11217648c6edc274e64b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c5f33d6126b18c3da6ae392c5959ee6ca8b361b9af93e24fd5d9f07aa296d4dfd53717bb87fa05496570b3480b4d19ee3512e22ea6a13931a7234e4d1f5f6c6
|
|
7
|
+
data.tar.gz: 3df0acd00f63f87a674907a70e65b4be172be997c323bfd5c36d3d56fc89cbe7ee72e108c395e674b1075a4618a10befab07ae4b158008c91a102475107d89ce
|
data/Gemfile.lock
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
gitlab-exporter (16.
|
|
4
|
+
gitlab-exporter (16.6.0)
|
|
5
5
|
connection_pool (= 2.5.5)
|
|
6
6
|
deep_merge (~> 1.2.2)
|
|
7
7
|
faraday (= 2.14.0)
|
|
8
8
|
pg (= 1.6.3)
|
|
9
|
-
puma (= 7.
|
|
9
|
+
puma (= 7.2.0)
|
|
10
10
|
quantile (= 0.2.1)
|
|
11
11
|
redis (= 4.8.1)
|
|
12
12
|
redis-namespace (= 1.11.0)
|
|
@@ -39,8 +39,8 @@ GEM
|
|
|
39
39
|
ast (~> 2.4.1)
|
|
40
40
|
racc
|
|
41
41
|
pg (1.6.3)
|
|
42
|
-
prism (1.
|
|
43
|
-
puma (7.
|
|
42
|
+
prism (1.9.0)
|
|
43
|
+
puma (7.2.0)
|
|
44
44
|
nio4r (~> 2.0)
|
|
45
45
|
quantile (0.2.1)
|
|
46
46
|
racc (1.8.1)
|
|
@@ -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.84.1)
|
|
70
70
|
json (~> 2.3)
|
|
71
71
|
language_server-protocol (~> 3.17.0.2)
|
|
72
72
|
lint_roller (~> 1.1.0)
|
|
@@ -74,12 +74,12 @@ 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.49.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.49.0)
|
|
81
81
|
parser (>= 3.3.7.2)
|
|
82
|
-
prism (~> 1.
|
|
82
|
+
prism (~> 1.7)
|
|
83
83
|
ruby-progressbar (1.13.0)
|
|
84
84
|
ruby2_keywords (0.0.5)
|
|
85
85
|
sidekiq (6.5.12)
|
data/gitlab-exporter.gemspec
CHANGED
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
s.add_runtime_dependency "deep_merge", "~> 1.2.2"
|
|
27
27
|
s.add_runtime_dependency "faraday", "2.14.0"
|
|
28
28
|
s.add_runtime_dependency "pg", "1.6.3"
|
|
29
|
-
s.add_runtime_dependency "puma", "7.
|
|
29
|
+
s.add_runtime_dependency "puma", "7.2.0"
|
|
30
30
|
s.add_runtime_dependency "quantile", "0.2.1"
|
|
31
31
|
s.add_runtime_dependency "redis", "4.8.1"
|
|
32
32
|
s.add_runtime_dependency "redis-namespace", "1.11.0"
|
|
@@ -28,12 +28,11 @@ module GitLab
|
|
|
28
28
|
SQL
|
|
29
29
|
|
|
30
30
|
ZOEKT_NODES_QUERY = <<~SQL.freeze
|
|
31
|
-
SELECT schema_version, id FROM zoekt_nodes
|
|
31
|
+
SELECT schema_version, id, metadata ->> 'name' AS node_name FROM zoekt_nodes
|
|
32
32
|
SQL
|
|
33
33
|
|
|
34
34
|
ZOEKT_NODES_STATUS_QUERY = <<~SQL.freeze
|
|
35
|
-
SELECT
|
|
36
|
-
id,
|
|
35
|
+
SELECT id, metadata ->> 'name' AS node_name,
|
|
37
36
|
CASE
|
|
38
37
|
WHEN last_seen_at < NOW() - INTERVAL '2 minute' THEN 0
|
|
39
38
|
ELSE 1
|
|
@@ -63,13 +62,51 @@ module GitLab
|
|
|
63
62
|
LIMIT 1
|
|
64
63
|
SQL
|
|
65
64
|
|
|
65
|
+
ZOEKT_NODE_STORAGE_QUERY = <<~SQL.freeze
|
|
66
|
+
SELECT
|
|
67
|
+
id,
|
|
68
|
+
metadata ->> 'name' AS node_name,
|
|
69
|
+
unclaimed_storage_bytes,
|
|
70
|
+
storage_percent_used
|
|
71
|
+
FROM zoekt_nodes
|
|
72
|
+
SQL
|
|
73
|
+
|
|
74
|
+
ZOEKT_REPOSITORIES_STATE_QUERY = <<~SQL.freeze
|
|
75
|
+
SELECT state, COUNT(*) FROM zoekt_repositories GROUP BY state
|
|
76
|
+
SQL
|
|
77
|
+
|
|
78
|
+
ZOEKT_INDICES_STATE_QUERY = <<~SQL.freeze
|
|
79
|
+
SELECT state, COUNT(*) FROM zoekt_indices GROUP BY state
|
|
80
|
+
SQL
|
|
81
|
+
|
|
82
|
+
ZOEKT_INDICES_WATERMARK_QUERY = <<~SQL.freeze
|
|
83
|
+
SELECT watermark_level, COUNT(*) FROM zoekt_indices GROUP BY watermark_level
|
|
84
|
+
SQL
|
|
85
|
+
|
|
86
|
+
ZOEKT_INDICES_STORAGE_QUERY = <<~SQL.freeze
|
|
87
|
+
SELECT
|
|
88
|
+
zoekt_indices.id,
|
|
89
|
+
zoekt_indices.reserved_storage_bytes,
|
|
90
|
+
zoekt_indices.used_storage_bytes,
|
|
91
|
+
zoekt_nodes.metadata ->> 'name' AS node_name
|
|
92
|
+
FROM
|
|
93
|
+
zoekt_indices
|
|
94
|
+
INNER JOIN
|
|
95
|
+
zoekt_nodes ON zoekt_indices.zoekt_node_id = zoekt_nodes.id
|
|
96
|
+
SQL
|
|
97
|
+
|
|
66
98
|
def run
|
|
67
99
|
return {} unless zoekt_indexing_enabled?
|
|
68
100
|
|
|
69
101
|
{
|
|
70
102
|
task_processing_query_result: execute(ZOEKT_TASKS_PROCESSING_QUERY, [Time.now.utc]),
|
|
71
103
|
repositories_schema_version_query_result: repositories_schema_version_query_result,
|
|
72
|
-
zoekt_nodes_status_query_result: execute(ZOEKT_NODES_STATUS_QUERY)
|
|
104
|
+
zoekt_nodes_status_query_result: execute(ZOEKT_NODES_STATUS_QUERY),
|
|
105
|
+
node_storage_query_result: execute(ZOEKT_NODE_STORAGE_QUERY),
|
|
106
|
+
repositories_state_query_result: execute(ZOEKT_REPOSITORIES_STATE_QUERY),
|
|
107
|
+
indices_state_query_result: execute(ZOEKT_INDICES_STATE_QUERY),
|
|
108
|
+
indices_watermark_query_result: execute(ZOEKT_INDICES_WATERMARK_QUERY),
|
|
109
|
+
indices_storage_query_result: execute(ZOEKT_INDICES_STORAGE_QUERY)
|
|
73
110
|
}.compact
|
|
74
111
|
end
|
|
75
112
|
|
|
@@ -88,22 +125,25 @@ module GitLab
|
|
|
88
125
|
|
|
89
126
|
hash = {}
|
|
90
127
|
zoekt_nodes.each do |row|
|
|
91
|
-
hash[row["id"]] = row["schema_version"]
|
|
128
|
+
hash[row["id"]] = [row["schema_version"], row["node_name"]]
|
|
92
129
|
end
|
|
93
130
|
hash
|
|
94
131
|
end
|
|
95
132
|
|
|
96
133
|
def zoekt_repository_schema_version_result(hash)
|
|
97
134
|
result = Set.new
|
|
98
|
-
hash.each do |id,
|
|
99
|
-
query_result = execute(ZOEKT_REPOSITORY_SCHEMA_VERSION_QUERY, [id,
|
|
135
|
+
hash.each do |id, schema_version_name_arr|
|
|
136
|
+
query_result = execute(ZOEKT_REPOSITORY_SCHEMA_VERSION_QUERY, [id, schema_version_name_arr[0]])
|
|
100
137
|
if query_result.nil?
|
|
101
138
|
result = nil
|
|
102
139
|
break
|
|
103
140
|
end
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
141
|
+
result.add(
|
|
142
|
+
{
|
|
143
|
+
target_schema_version: schema_version_name_arr[0], zoekt_node_id: id,
|
|
144
|
+
zoekt_node_name: schema_version_name_arr[1], unfinished_repository_count: query_result[0]["count"].to_i
|
|
145
|
+
}
|
|
146
|
+
)
|
|
107
147
|
end
|
|
108
148
|
result
|
|
109
149
|
end
|
|
@@ -129,6 +169,7 @@ module GitLab
|
|
|
129
169
|
end
|
|
130
170
|
|
|
131
171
|
# The prober which is called when gathering metrics
|
|
172
|
+
# rubocop:disable Metrics/ClassLength
|
|
132
173
|
class ZoektProber
|
|
133
174
|
PrometheusMetrics.describe(
|
|
134
175
|
"search_zoekt_task_processing_queue_size",
|
|
@@ -148,6 +189,48 @@ module GitLab
|
|
|
148
189
|
"gauge"
|
|
149
190
|
)
|
|
150
191
|
|
|
192
|
+
PrometheusMetrics.describe(
|
|
193
|
+
"search_zoekt_node_unclaimed_storage_bytes",
|
|
194
|
+
"Unclaimed storage bytes for Zoekt node",
|
|
195
|
+
"gauge"
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
PrometheusMetrics.describe(
|
|
199
|
+
"search_zoekt_node_storage_percent_used",
|
|
200
|
+
"Fraction of storage used on Zoekt node (0..1)",
|
|
201
|
+
"gauge"
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
PrometheusMetrics.describe(
|
|
205
|
+
"search_zoekt_repositories_states_total",
|
|
206
|
+
"Number of Zoekt repositories in each state",
|
|
207
|
+
"gauge"
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
PrometheusMetrics.describe(
|
|
211
|
+
"search_zoekt_indices_states",
|
|
212
|
+
"Number of Zoekt indices in each state",
|
|
213
|
+
"gauge"
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
PrometheusMetrics.describe(
|
|
217
|
+
"search_zoekt_indices_watermark_levels",
|
|
218
|
+
"Number of Zoekt indices in each watermark level",
|
|
219
|
+
"gauge"
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
PrometheusMetrics.describe(
|
|
223
|
+
"search_zoekt_indices_reserved_storage_bytes",
|
|
224
|
+
"Reserved storage bytes for each Zoekt index",
|
|
225
|
+
"gauge"
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
PrometheusMetrics.describe(
|
|
229
|
+
"search_zoekt_indices_used_storage_bytes",
|
|
230
|
+
"Used storage bytes for each Zoekt index",
|
|
231
|
+
"gauge"
|
|
232
|
+
)
|
|
233
|
+
|
|
151
234
|
def initialize(metrics: PrometheusMetrics.new, **opts)
|
|
152
235
|
@metrics = metrics
|
|
153
236
|
@collector = opts[:collector] || ZoektCollector.new(**opts)
|
|
@@ -155,27 +238,68 @@ module GitLab
|
|
|
155
238
|
|
|
156
239
|
def probe_db
|
|
157
240
|
results = @collector.run
|
|
158
|
-
results
|
|
159
|
-
add_processing_zoekt_tasks_to_metric(row)
|
|
160
|
-
end
|
|
161
|
-
results[:repositories_schema_version_query_result]&.each do |row|
|
|
162
|
-
add_zoekt_repositories_by_schema_version_to_metric(row)
|
|
163
|
-
end
|
|
164
|
-
results[:zoekt_nodes_status_query_result]&.each do |row|
|
|
165
|
-
add_zoekt_nodes_status_to_metric(row)
|
|
166
|
-
end
|
|
167
|
-
|
|
241
|
+
process_results(results)
|
|
168
242
|
self
|
|
169
243
|
rescue PG::ConnectionBad
|
|
170
244
|
self
|
|
171
245
|
end
|
|
172
246
|
|
|
247
|
+
private
|
|
248
|
+
|
|
249
|
+
def process_results(results)
|
|
250
|
+
process_task_results(results[:task_processing_query_result])
|
|
251
|
+
process_repository_results(results[:repositories_schema_version_query_result])
|
|
252
|
+
process_node_status_results(results[:zoekt_nodes_status_query_result])
|
|
253
|
+
process_node_storage_results(results[:node_storage_query_result])
|
|
254
|
+
process_repositories_state_results(results[:repositories_state_query_result])
|
|
255
|
+
process_indices_state_results(results[:indices_state_query_result])
|
|
256
|
+
process_indices_watermark_results(results[:indices_watermark_query_result])
|
|
257
|
+
process_indices_storage_results(results[:indices_storage_query_result])
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def process_task_results(results)
|
|
261
|
+
results.to_a.each { |row| add_processing_zoekt_tasks_to_metric(row) }
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def process_repository_results(results)
|
|
265
|
+
results&.each { |row| add_zoekt_repositories_by_schema_version_to_metric(row) }
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def process_node_status_results(results)
|
|
269
|
+
results&.each { |row| add_zoekt_nodes_status_to_metric(row) }
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def process_node_storage_results(results)
|
|
273
|
+
results&.each do |row|
|
|
274
|
+
add_zoekt_node_unclaimed_storage_to_metric(row)
|
|
275
|
+
add_zoekt_node_storage_percent_used_to_metric(row)
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def process_repositories_state_results(results)
|
|
280
|
+
results&.each { |row| add_zoekt_repositories_state_to_metric(row) }
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def process_indices_state_results(results)
|
|
284
|
+
results&.each { |row| add_zoekt_indices_state_to_metric(row) }
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def process_indices_watermark_results(results)
|
|
288
|
+
results&.each { |row| add_zoekt_indices_watermark_to_metric(row) }
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
def process_indices_storage_results(results)
|
|
292
|
+
results&.each { |row| add_zoekt_indices_storage_to_metric(row) }
|
|
293
|
+
end
|
|
294
|
+
|
|
173
295
|
def add_processing_zoekt_tasks_to_metric(row)
|
|
174
296
|
@metrics.add(
|
|
175
297
|
"search_zoekt_task_processing_queue_size",
|
|
176
298
|
row["task_count"].to_i,
|
|
177
|
-
|
|
178
|
-
|
|
299
|
+
**{
|
|
300
|
+
node_name: row["node_name"],
|
|
301
|
+
node_id: row["node_id"]
|
|
302
|
+
}.compact
|
|
179
303
|
)
|
|
180
304
|
end
|
|
181
305
|
|
|
@@ -183,8 +307,11 @@ module GitLab
|
|
|
183
307
|
@metrics.add(
|
|
184
308
|
"search_zoekt_repositories_schema_version_count",
|
|
185
309
|
row[:unfinished_repository_count].to_i,
|
|
186
|
-
|
|
187
|
-
|
|
310
|
+
**{
|
|
311
|
+
target_schema_version: row[:target_schema_version],
|
|
312
|
+
zoekt_node_id: row[:zoekt_node_id],
|
|
313
|
+
zoekt_node_name: row[:zoekt_node_name]
|
|
314
|
+
}.compact
|
|
188
315
|
)
|
|
189
316
|
end
|
|
190
317
|
|
|
@@ -192,14 +319,91 @@ module GitLab
|
|
|
192
319
|
@metrics.add(
|
|
193
320
|
"search_zoekt_nodes_status",
|
|
194
321
|
row["status"].to_i,
|
|
195
|
-
|
|
322
|
+
**{
|
|
323
|
+
zoekt_node_id: row["id"],
|
|
324
|
+
zoekt_node_name: row["node_name"]
|
|
325
|
+
}.compact
|
|
326
|
+
)
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
def add_zoekt_node_unclaimed_storage_to_metric(row)
|
|
330
|
+
@metrics.add(
|
|
331
|
+
"search_zoekt_node_unclaimed_storage_bytes",
|
|
332
|
+
row["unclaimed_storage_bytes"].to_i,
|
|
333
|
+
**{
|
|
334
|
+
zoekt_node_id: row["id"],
|
|
335
|
+
zoekt_node_name: row["node_name"]
|
|
336
|
+
}.compact
|
|
337
|
+
)
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
def add_zoekt_node_storage_percent_used_to_metric(row)
|
|
341
|
+
@metrics.add(
|
|
342
|
+
"search_zoekt_node_storage_percent_used",
|
|
343
|
+
row["storage_percent_used"].to_f,
|
|
344
|
+
**{
|
|
345
|
+
zoekt_node_id: row["id"],
|
|
346
|
+
zoekt_node_name: row["node_name"]
|
|
347
|
+
}.compact
|
|
348
|
+
)
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
def add_zoekt_repositories_state_to_metric(row)
|
|
352
|
+
@metrics.add(
|
|
353
|
+
"search_zoekt_repositories_states_total",
|
|
354
|
+
row["count"].to_i,
|
|
355
|
+
**{
|
|
356
|
+
state: row["state"]
|
|
357
|
+
}.compact
|
|
358
|
+
)
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
def add_zoekt_indices_state_to_metric(row)
|
|
362
|
+
@metrics.add(
|
|
363
|
+
"search_zoekt_indices_states",
|
|
364
|
+
row["count"].to_i,
|
|
365
|
+
**{
|
|
366
|
+
state: row["state"]
|
|
367
|
+
}.compact
|
|
368
|
+
)
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def add_zoekt_indices_watermark_to_metric(row)
|
|
372
|
+
@metrics.add(
|
|
373
|
+
"search_zoekt_indices_watermark_levels",
|
|
374
|
+
row["count"].to_i,
|
|
375
|
+
**{
|
|
376
|
+
watermark_level: row["watermark_level"]
|
|
377
|
+
}.compact
|
|
378
|
+
)
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
# rubocop:disable Metrics/MethodLength
|
|
382
|
+
def add_zoekt_indices_storage_to_metric(row)
|
|
383
|
+
@metrics.add(
|
|
384
|
+
"search_zoekt_indices_reserved_storage_bytes",
|
|
385
|
+
row["reserved_storage_bytes"].to_i,
|
|
386
|
+
**{
|
|
387
|
+
zoekt_index_id: row["id"],
|
|
388
|
+
zoekt_node_name: row["node_name"]
|
|
389
|
+
}.compact
|
|
390
|
+
)
|
|
391
|
+
@metrics.add(
|
|
392
|
+
"search_zoekt_indices_used_storage_bytes",
|
|
393
|
+
row["used_storage_bytes"].to_i,
|
|
394
|
+
**{
|
|
395
|
+
zoekt_index_id: row["id"],
|
|
396
|
+
zoekt_node_name: row["node_name"]
|
|
397
|
+
}.compact
|
|
196
398
|
)
|
|
197
399
|
end
|
|
400
|
+
# rubocop:enable Metrics/MethodLength
|
|
198
401
|
|
|
199
402
|
def write_to(target)
|
|
200
403
|
target.write(@metrics.to_s)
|
|
201
404
|
end
|
|
202
405
|
end
|
|
406
|
+
# rubocop:enable Metrics/ClassLength
|
|
203
407
|
end
|
|
204
408
|
end
|
|
205
409
|
end
|
data/spec/database/zoekt_spec.rb
CHANGED
|
@@ -6,11 +6,36 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
6
6
|
let(:connection) { double("connection") }
|
|
7
7
|
let(:zoekt_tasks_processing_query) { described_class::ZOEKT_TASKS_PROCESSING_QUERY }
|
|
8
8
|
let(:zoekt_nodes_query) { described_class::ZOEKT_NODES_QUERY }
|
|
9
|
-
let(:zoekt_nodes_query_results) { [{ "id" => "1", "schema_version" => "2302" }] }
|
|
9
|
+
let(:zoekt_nodes_query_results) { [{ "id" => "1", "schema_version" => "2302", "node_name" => "foo" }] }
|
|
10
10
|
let(:zoekt_enabled_query) { described_class::ZOEKT_ENABLED_QUERY }
|
|
11
11
|
let(:zoekt_repository_schema_version_query) { described_class::ZOEKT_REPOSITORY_SCHEMA_VERSION_QUERY }
|
|
12
12
|
let(:zoekt_nodes_status_query) { described_class::ZOEKT_NODES_STATUS_QUERY }
|
|
13
|
-
let(:zoekt_nodes_status_query_results) { [{ "id" => "1", "status" => "1" }] }
|
|
13
|
+
let(:zoekt_nodes_status_query_results) { [{ "id" => "1", "name" => "foo", "status" => "1" }] }
|
|
14
|
+
let(:zoekt_node_storage_query) { described_class::ZOEKT_NODE_STORAGE_QUERY }
|
|
15
|
+
let(:zoekt_node_storage_query_results) do
|
|
16
|
+
[{ "id" => "1", "node_name" => "foo", "unclaimed_storage_bytes" => "1000000", "storage_percent_used" => "0.75" }]
|
|
17
|
+
end
|
|
18
|
+
let(:zoekt_repositories_state_query) { described_class::ZOEKT_REPOSITORIES_STATE_QUERY }
|
|
19
|
+
let(:zoekt_repositories_state_query_results) do
|
|
20
|
+
[{ "state" => "0", "count" => "5" }, { "state" => "10", "count" => "15" }]
|
|
21
|
+
end
|
|
22
|
+
let(:zoekt_indices_state_query) { described_class::ZOEKT_INDICES_STATE_QUERY }
|
|
23
|
+
let(:zoekt_indices_state_query_results) do
|
|
24
|
+
[{ "state" => "0", "count" => "3" }, { "state" => "1", "count" => "7" }]
|
|
25
|
+
end
|
|
26
|
+
let(:zoekt_indices_watermark_query) { described_class::ZOEKT_INDICES_WATERMARK_QUERY }
|
|
27
|
+
let(:zoekt_indices_watermark_query_results) do
|
|
28
|
+
[{ "watermark_level" => "healthy", "count" => "8" }, { "watermark_level" => "warning", "count" => "2" }]
|
|
29
|
+
end
|
|
30
|
+
let(:zoekt_indices_storage_query) { described_class::ZOEKT_INDICES_STORAGE_QUERY }
|
|
31
|
+
let(:zoekt_indices_storage_query_results) do
|
|
32
|
+
[
|
|
33
|
+
{ "id" => "1", "reserved_storage_bytes" => "1000000", "used_storage_bytes" => "500000",
|
|
34
|
+
"node_name" => "zoekt-1" },
|
|
35
|
+
{ "id" => "2", "reserved_storage_bytes" => "2000000", "used_storage_bytes" => "1500000",
|
|
36
|
+
"node_name" => "zoekt-2" }
|
|
37
|
+
]
|
|
38
|
+
end
|
|
14
39
|
|
|
15
40
|
let(:zoekt_repository_schema_version_query_results) { [{ "count" => "1" }] }
|
|
16
41
|
|
|
@@ -41,14 +66,21 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
41
66
|
end
|
|
42
67
|
|
|
43
68
|
let(:zoekt_repositories_schema_version_query_results) do
|
|
44
|
-
Set.new(
|
|
69
|
+
Set.new(
|
|
70
|
+
[{ target_schema_version: "2302", zoekt_node_id: "1", zoekt_node_name: "foo", unfinished_repository_count: 1 }]
|
|
71
|
+
)
|
|
45
72
|
end
|
|
46
73
|
|
|
47
74
|
let(:result) do
|
|
48
75
|
{
|
|
49
76
|
repositories_schema_version_query_result: zoekt_repositories_schema_version_query_results,
|
|
50
77
|
task_processing_query_result: zoekt_tasks_processing_query_results,
|
|
51
|
-
zoekt_nodes_status_query_result: zoekt_nodes_status_query_results
|
|
78
|
+
zoekt_nodes_status_query_result: zoekt_nodes_status_query_results,
|
|
79
|
+
node_storage_query_result: zoekt_node_storage_query_results,
|
|
80
|
+
repositories_state_query_result: zoekt_repositories_state_query_results,
|
|
81
|
+
indices_state_query_result: zoekt_indices_state_query_results,
|
|
82
|
+
indices_watermark_query_result: zoekt_indices_watermark_query_results,
|
|
83
|
+
indices_storage_query_result: zoekt_indices_storage_query_results
|
|
52
84
|
}
|
|
53
85
|
end
|
|
54
86
|
|
|
@@ -80,6 +112,16 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
80
112
|
.and_return(zoekt_repository_schema_version_query_results)
|
|
81
113
|
expect(connection).to receive(:exec_params).with(zoekt_nodes_status_query, [])
|
|
82
114
|
.and_return(zoekt_nodes_status_query_results)
|
|
115
|
+
expect(connection).to receive(:exec_params).with(zoekt_node_storage_query, [])
|
|
116
|
+
.and_return(zoekt_node_storage_query_results)
|
|
117
|
+
expect(connection).to receive(:exec_params).with(zoekt_repositories_state_query, [])
|
|
118
|
+
.and_return(zoekt_repositories_state_query_results)
|
|
119
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_state_query, [])
|
|
120
|
+
.and_return(zoekt_indices_state_query_results)
|
|
121
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_watermark_query, [])
|
|
122
|
+
.and_return(zoekt_indices_watermark_query_results)
|
|
123
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_storage_query, [])
|
|
124
|
+
.and_return(zoekt_indices_storage_query_results)
|
|
83
125
|
|
|
84
126
|
expect(collector.run).to eq(result)
|
|
85
127
|
end
|
|
@@ -92,6 +134,16 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
92
134
|
.and_raise(PG::UndefinedTable)
|
|
93
135
|
allow(connection).to receive(:exec_params).with(zoekt_nodes_status_query, [])
|
|
94
136
|
.and_raise(PG::UndefinedTable)
|
|
137
|
+
allow(connection).to receive(:exec_params).with(zoekt_node_storage_query, [])
|
|
138
|
+
.and_raise(PG::UndefinedTable)
|
|
139
|
+
allow(connection).to receive(:exec_params).with(zoekt_repositories_state_query, [])
|
|
140
|
+
.and_raise(PG::UndefinedTable)
|
|
141
|
+
allow(connection).to receive(:exec_params).with(zoekt_indices_state_query, [])
|
|
142
|
+
.and_raise(PG::UndefinedTable)
|
|
143
|
+
allow(connection).to receive(:exec_params).with(zoekt_indices_watermark_query, [])
|
|
144
|
+
.and_raise(PG::UndefinedTable)
|
|
145
|
+
allow(connection).to receive(:exec_params).with(zoekt_indices_storage_query, [])
|
|
146
|
+
.and_raise(PG::UndefinedTable)
|
|
95
147
|
|
|
96
148
|
expect(collector.run).to eq({})
|
|
97
149
|
end
|
|
@@ -106,6 +158,15 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
106
158
|
expect(connection).to receive(:exec_params).with(zoekt_repository_schema_version_query, %w[1 2302])
|
|
107
159
|
.and_raise(PG::UndefinedTable)
|
|
108
160
|
expect(connection).to receive(:exec_params).with(zoekt_nodes_status_query, []).and_raise(PG::UndefinedTable)
|
|
161
|
+
expect(connection).to receive(:exec_params).with(zoekt_node_storage_query, []).and_raise(PG::UndefinedColumn)
|
|
162
|
+
expect(connection).to receive(:exec_params).with(zoekt_repositories_state_query, [])
|
|
163
|
+
.and_raise(PG::UndefinedColumn)
|
|
164
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_state_query, [])
|
|
165
|
+
.and_raise(PG::UndefinedColumn)
|
|
166
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_watermark_query, [])
|
|
167
|
+
.and_raise(PG::UndefinedColumn)
|
|
168
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_storage_query, [])
|
|
169
|
+
.and_raise(PG::UndefinedColumn)
|
|
109
170
|
|
|
110
171
|
expect(collector.run).to eq({ task_processing_query_result: zoekt_tasks_processing_query_results })
|
|
111
172
|
end
|
|
@@ -136,11 +197,39 @@ describe GitLab::Exporter::Database::ZoektProber do
|
|
|
136
197
|
let(:data) do
|
|
137
198
|
{
|
|
138
199
|
repositories_schema_version_query_result: Set.new(
|
|
139
|
-
[{ target_schema_version: "2302", zoekt_node_id: "1", unfinished_repository_count: 1 }]
|
|
200
|
+
[{ target_schema_version: "2302", zoekt_node_id: "1", unfinished_repository_count: 1, zoekt_node_name: "foo" }]
|
|
140
201
|
),
|
|
141
202
|
task_processing_query_result: [
|
|
142
203
|
{ "node_id" => "1", "node_name" => "zoekt-1", "task_count" => "5" },
|
|
143
204
|
{ "node_id" => "2", "node_name" => "zoekt-2", "task_count" => "10" }
|
|
205
|
+
],
|
|
206
|
+
node_storage_query_result: [
|
|
207
|
+
{
|
|
208
|
+
"id" => "1", "node_name" => "zoekt-1", "unclaimed_storage_bytes" => "1000000",
|
|
209
|
+
"storage_percent_used" => "0.75"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"id" => "2", "node_name" => "zoekt-2", "unclaimed_storage_bytes" => "2000000",
|
|
213
|
+
"storage_percent_used" => "0.50"
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
repositories_state_query_result: [
|
|
217
|
+
{ "state" => "0", "count" => "5" },
|
|
218
|
+
{ "state" => "10", "count" => "15" }
|
|
219
|
+
],
|
|
220
|
+
indices_state_query_result: [
|
|
221
|
+
{ "state" => "0", "count" => "3" },
|
|
222
|
+
{ "state" => "1", "count" => "7" }
|
|
223
|
+
],
|
|
224
|
+
indices_watermark_query_result: [
|
|
225
|
+
{ "watermark_level" => "healthy", "count" => "8" },
|
|
226
|
+
{ "watermark_level" => "warning", "count" => "2" }
|
|
227
|
+
],
|
|
228
|
+
indices_storage_query_result: [
|
|
229
|
+
{ "id" => "1", "reserved_storage_bytes" => "1000000", "used_storage_bytes" => "500000",
|
|
230
|
+
"node_name" => "zoekt-1" },
|
|
231
|
+
{ "id" => "2", "reserved_storage_bytes" => "2000000", "used_storage_bytes" => "1500000",
|
|
232
|
+
"node_name" => "zoekt-2" }
|
|
144
233
|
]
|
|
145
234
|
}
|
|
146
235
|
end
|
|
@@ -165,10 +254,12 @@ describe GitLab::Exporter::Database::ZoektProber do
|
|
|
165
254
|
|
|
166
255
|
data[:task_processing_query_result].each do |node_data|
|
|
167
256
|
expect(metrics).to receive(:add)
|
|
168
|
-
.with(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
257
|
+
.with(
|
|
258
|
+
"search_zoekt_task_processing_queue_size",
|
|
259
|
+
node_data["task_count"].to_i,
|
|
260
|
+
node_name: node_data["node_name"],
|
|
261
|
+
node_id: node_data["node_id"]
|
|
262
|
+
)
|
|
172
263
|
end
|
|
173
264
|
|
|
174
265
|
data[:repositories_schema_version_query_result].each do |node_data|
|
|
@@ -177,7 +268,69 @@ describe GitLab::Exporter::Database::ZoektProber do
|
|
|
177
268
|
"search_zoekt_repositories_schema_version_count",
|
|
178
269
|
node_data[:unfinished_repository_count].to_i,
|
|
179
270
|
target_schema_version: node_data[:target_schema_version],
|
|
180
|
-
zoekt_node_id: node_data[:zoekt_node_id]
|
|
271
|
+
zoekt_node_id: node_data[:zoekt_node_id],
|
|
272
|
+
zoekt_node_name: node_data[:zoekt_node_name]
|
|
273
|
+
)
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
data[:node_storage_query_result].each do |node_data|
|
|
277
|
+
expect(metrics).to receive(:add)
|
|
278
|
+
.with(
|
|
279
|
+
"search_zoekt_node_unclaimed_storage_bytes",
|
|
280
|
+
node_data["unclaimed_storage_bytes"].to_i,
|
|
281
|
+
zoekt_node_id: node_data["id"],
|
|
282
|
+
zoekt_node_name: node_data["node_name"]
|
|
283
|
+
)
|
|
284
|
+
expect(metrics).to receive(:add)
|
|
285
|
+
.with(
|
|
286
|
+
"search_zoekt_node_storage_percent_used",
|
|
287
|
+
node_data["storage_percent_used"].to_f,
|
|
288
|
+
zoekt_node_id: node_data["id"],
|
|
289
|
+
zoekt_node_name: node_data["node_name"]
|
|
290
|
+
)
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
data[:repositories_state_query_result].each do |state_data|
|
|
294
|
+
expect(metrics).to receive(:add)
|
|
295
|
+
.with(
|
|
296
|
+
"search_zoekt_repositories_states_total",
|
|
297
|
+
state_data["count"].to_i,
|
|
298
|
+
state: state_data["state"]
|
|
299
|
+
)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
data[:indices_state_query_result].each do |state_data|
|
|
303
|
+
expect(metrics).to receive(:add)
|
|
304
|
+
.with(
|
|
305
|
+
"search_zoekt_indices_states",
|
|
306
|
+
state_data["count"].to_i,
|
|
307
|
+
state: state_data["state"]
|
|
308
|
+
)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
data[:indices_watermark_query_result].each do |watermark_data|
|
|
312
|
+
expect(metrics).to receive(:add)
|
|
313
|
+
.with(
|
|
314
|
+
"search_zoekt_indices_watermark_levels",
|
|
315
|
+
watermark_data["count"].to_i,
|
|
316
|
+
watermark_level: watermark_data["watermark_level"]
|
|
317
|
+
)
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
data[:indices_storage_query_result].each do |storage_data|
|
|
321
|
+
expect(metrics).to receive(:add)
|
|
322
|
+
.with(
|
|
323
|
+
"search_zoekt_indices_reserved_storage_bytes",
|
|
324
|
+
storage_data["reserved_storage_bytes"].to_i,
|
|
325
|
+
zoekt_index_id: storage_data["id"],
|
|
326
|
+
zoekt_node_name: storage_data["node_name"]
|
|
327
|
+
)
|
|
328
|
+
expect(metrics).to receive(:add)
|
|
329
|
+
.with(
|
|
330
|
+
"search_zoekt_indices_used_storage_bytes",
|
|
331
|
+
storage_data["used_storage_bytes"].to_i,
|
|
332
|
+
zoekt_index_id: storage_data["id"],
|
|
333
|
+
zoekt_node_name: storage_data["node_name"]
|
|
181
334
|
)
|
|
182
335
|
end
|
|
183
336
|
|
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.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pablo Carranza
|
|
@@ -72,14 +72,14 @@ dependencies:
|
|
|
72
72
|
requirements:
|
|
73
73
|
- - '='
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 7.
|
|
75
|
+
version: 7.2.0
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - '='
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 7.
|
|
82
|
+
version: 7.2.0
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: quantile
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|