gitlab-exporter 10.5.0 → 11.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 +1 -1
- data/lib/gitlab_exporter/cli.rb +1 -1
- data/lib/gitlab_exporter/sidekiq.rb +7 -36
- data/lib/gitlab_exporter/version.rb +1 -1
- metadata +1 -2
- data/lib/gitlab_exporter/sidekiq_queue_job_stats.lua +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f22f9c58b0d64fdec6134fa8b59cfd474f1333ebe59a8a94c620749fc4be33c
|
4
|
+
data.tar.gz: 0dc26d62d7aab597a13aab640844a42774a85c2ce6459f9eeeef7441b81f3d19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56a1c9f3a267b32ead646a1c6a95a8d81744498d67613e0c6dbb849a15e624d96215800a1688504e08c8b25a2b1222a4b86f2e3b1cb7b898ff892f6a445dcdbd
|
7
|
+
data.tar.gz: e08257d194617fd5467526403a8629aeab1d46719bb34c57b6aaaa77cb94b138b139544771b071bfccc6ec47e8440d1241ae3adb8fceb226694366d4e89a058f
|
data/Gemfile.lock
CHANGED
data/lib/gitlab_exporter/cli.rb
CHANGED
@@ -7,9 +7,6 @@ module GitLab
|
|
7
7
|
#
|
8
8
|
# It takes the Redis URL Sidekiq is connected to
|
9
9
|
class SidekiqProber
|
10
|
-
QUEUE_JOB_STATS_SCRIPT = File.read(File.expand_path("#{__FILE__}/../sidekiq_queue_job_stats.lua")).freeze
|
11
|
-
QUEUE_JOB_STATS_SHA = Digest::SHA1.hexdigest(QUEUE_JOB_STATS_SCRIPT).freeze
|
12
|
-
|
13
10
|
# The maximum depth (from the head) of each queue to probe. Probing the
|
14
11
|
# entirety of a very large queue will take longer and run the risk of
|
15
12
|
# timing out. But when we have a very large queue, we are most in need of
|
@@ -72,45 +69,19 @@ module GitLab
|
|
72
69
|
self
|
73
70
|
end
|
74
71
|
|
75
|
-
# Count worker classes present in Sidekiq queues. This uses a Lua
|
76
|
-
# script to find all jobs in all queues. That script will block
|
77
|
-
# all other Redis commands:
|
78
|
-
# https://redis.io/commands/eval#atomicity-of-scripts
|
79
|
-
#
|
80
|
-
# The script is generally fast, but may be slower with very large
|
81
|
-
# queues, which is why this is not enabled by default.
|
82
72
|
def probe_jobs
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
Sidekiq::Queue.all.each do |queue|
|
87
|
-
Sidekiq.redis do |conn|
|
88
|
-
stats = conn.evalsha(QUEUE_JOB_STATS_SHA, ["queue:#{queue.name}"])
|
89
|
-
job_stats.merge!(stats.to_h)
|
90
|
-
end
|
91
|
-
rescue Redis::CommandError # Could happen if the script exceeded the maximum run time (5 seconds by default)
|
92
|
-
# FIXME: Should we call SCRIPT KILL?
|
93
|
-
return self
|
94
|
-
end
|
95
|
-
|
96
|
-
job_stats.each do |class_name, count|
|
97
|
-
@metrics.add("sidekiq_enqueued_jobs", count, name: class_name)
|
98
|
-
end
|
99
|
-
end
|
73
|
+
puts "[REMOVED] probe_jobs is now considered obsolete and does not emit any metrics,"\
|
74
|
+
" please use probe_jobs_limit instead"
|
100
75
|
|
101
76
|
self
|
102
77
|
end
|
103
78
|
|
104
|
-
#
|
105
|
-
# PROBE_JOBS_LIMIT jobs in each queue. This means that we run a
|
79
|
+
# Count worker classes present in Sidekiq queues. This only looks at the
|
80
|
+
# first PROBE_JOBS_LIMIT jobs in each queue. This means that we run a
|
106
81
|
# single LRANGE command for each queue, which does not block other
|
107
|
-
# commands. For queues over PROBE_JOBS_LIMIT in size, this means
|
108
|
-
#
|
109
|
-
#
|
110
|
-
# larger.
|
111
|
-
#
|
112
|
-
# DO NOT USE this and probe_jobs together, as they export the same
|
113
|
-
# metric (sidekiq_enqueued_jobs).
|
82
|
+
# commands. For queues over PROBE_JOBS_LIMIT in size, this means that we
|
83
|
+
# will not have completely accurate statistics, but the probe performance
|
84
|
+
# will also not degrade as the queue gets larger.
|
114
85
|
def probe_jobs_limit
|
115
86
|
with_sidekiq do
|
116
87
|
job_stats = Hash.new(0)
|
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:
|
4
|
+
version: 11.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Carranza
|
@@ -189,7 +189,6 @@ files:
|
|
189
189
|
- lib/gitlab_exporter/prometheus.rb
|
190
190
|
- lib/gitlab_exporter/ruby.rb
|
191
191
|
- lib/gitlab_exporter/sidekiq.rb
|
192
|
-
- lib/gitlab_exporter/sidekiq_queue_job_stats.lua
|
193
192
|
- lib/gitlab_exporter/util.rb
|
194
193
|
- lib/gitlab_exporter/version.rb
|
195
194
|
- lib/gitlab_exporter/web_exporter.rb
|
@@ -1,42 +0,0 @@
|
|
1
|
-
--
|
2
|
-
-- Adapted from https://github.com/mperham/sidekiq/blob/2f9258e4fe77991c526f7a65c92bcf792eef8338/lib/sidekiq/api.rb#L231
|
3
|
-
--
|
4
|
-
local queue_name = KEYS[1]
|
5
|
-
local initial_size = redis.call('llen', queue_name)
|
6
|
-
local deleted_size = 0
|
7
|
-
local page = 0
|
8
|
-
local page_size = 2000
|
9
|
-
local temp_job_stats = {}
|
10
|
-
local final_job_stats = {}
|
11
|
-
|
12
|
-
while true do
|
13
|
-
local range_start = page * page_size - deleted_size
|
14
|
-
local range_end = range_start + page_size - 1
|
15
|
-
local entries = redis.call('lrange', queue_name, range_start, range_end)
|
16
|
-
|
17
|
-
if #entries == 0 then
|
18
|
-
break
|
19
|
-
end
|
20
|
-
|
21
|
-
page = page + 1
|
22
|
-
|
23
|
-
for index, entry in next, entries do
|
24
|
-
local class = cjson.decode(entry)['class']
|
25
|
-
if class ~= nil then
|
26
|
-
if temp_job_stats[class] ~= nil then
|
27
|
-
temp_job_stats[class] = temp_job_stats[class] + 1
|
28
|
-
else
|
29
|
-
temp_job_stats[class] = 1
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
deleted_size = initial_size - redis.call('llen', queue_name)
|
35
|
-
end
|
36
|
-
|
37
|
-
for class, count in next, temp_job_stats do
|
38
|
-
local stat_entry = {class, count}
|
39
|
-
table.insert(final_job_stats, stat_entry)
|
40
|
-
end
|
41
|
-
|
42
|
-
return final_job_stats
|