sidekiq-prometheus-exporter 0.4.0 → 0.5.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/.gitignore +0 -1
- data/.rubocop.yml +12 -2
- data/Gemfile +4 -4
- data/Gemfile.lock +146 -0
- data/README.md +1 -0
- data/lib/sidekiq/prometheus/exporter/exporters.rb +1 -1
- data/lib/sidekiq/prometheus/exporter/standard.rb +26 -10
- data/lib/sidekiq/prometheus/exporter/templates/standard.erb +10 -2
- data/lib/sidekiq/prometheus/exporter/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 56cae6d941f563aa7c9394e747815e11ca1d695dc168f52caac96e597652df4e
|
|
4
|
+
data.tar.gz: 5aa4fd4d5dc4a0e7636e070723b7534317ec0137e802a5e37f49f482e480f44b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc040fa6f6129f37bb4ddb28d5508456b200b02b63b7b07681d9b34d460e6ce717d39f6da94ad28a1125e34ed27a76f62035f555f17b1b647cd70f49f788659c
|
|
7
|
+
data.tar.gz: 62bd53ba39825d26f89ca2ced7fd7fe17fa8bed97d5a855320d9679f9140e4acf029173aa29f1ed9827a207aa34f459d3b47c55058252b971987a99644505850
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
plugins:
|
|
3
3
|
- rubocop-rake
|
|
4
4
|
- rubocop-rspec
|
|
5
5
|
- rubocop-performance
|
|
@@ -18,6 +18,10 @@ Gemspec/RequiredRubyVersion:
|
|
|
18
18
|
Style/Documentation:
|
|
19
19
|
Enabled: false
|
|
20
20
|
|
|
21
|
+
Style/OneClassPerFile:
|
|
22
|
+
Exclude:
|
|
23
|
+
- "examples/**/*"
|
|
24
|
+
|
|
21
25
|
Style/FrozenStringLiteralComment:
|
|
22
26
|
EnforcedStyle: always
|
|
23
27
|
Exclude:
|
|
@@ -71,10 +75,16 @@ Layout/MultilineOperationIndentation:
|
|
|
71
75
|
EnforcedStyle: indented
|
|
72
76
|
IndentationWidth: ~
|
|
73
77
|
|
|
78
|
+
Layout/FirstHashElementIndentation:
|
|
79
|
+
EnforcedStyle: consistent
|
|
80
|
+
|
|
74
81
|
Metrics/AbcSize:
|
|
75
82
|
Max: 35
|
|
76
83
|
CountRepeatedAttributes: false
|
|
77
84
|
|
|
85
|
+
Metrics/ClassLength:
|
|
86
|
+
Max: 120
|
|
87
|
+
|
|
78
88
|
Metrics/MethodLength:
|
|
79
89
|
Max: 15
|
|
80
90
|
|
|
@@ -119,7 +129,7 @@ RSpec/MultipleExpectations:
|
|
|
119
129
|
Max: 5
|
|
120
130
|
|
|
121
131
|
RSpec/MultipleMemoizedHelpers:
|
|
122
|
-
Max:
|
|
132
|
+
Max: 10
|
|
123
133
|
|
|
124
134
|
RSpec/NestedGroups:
|
|
125
135
|
Enabled: true
|
data/Gemfile
CHANGED
|
@@ -13,12 +13,12 @@ gem 'logger', '~> 1.7'
|
|
|
13
13
|
gem 'ostruct', '~> 0.6'
|
|
14
14
|
gem 'pry', '~> 0.15'
|
|
15
15
|
gem 'pry-byebug', '~> 3.6'
|
|
16
|
-
gem 'readline-ext', '~> 0.2'
|
|
17
16
|
gem 'rack-test', '>= 1.1'
|
|
18
17
|
gem 'rake', '~> 13.0'
|
|
18
|
+
gem 'readline-ext', '~> 0.2'
|
|
19
19
|
gem 'rspec', '~> 3.0'
|
|
20
|
-
gem 'rubocop', '~> 1.
|
|
21
|
-
gem 'rubocop-performance', '~> 1.
|
|
20
|
+
gem 'rubocop', '~> 1.75'
|
|
21
|
+
gem 'rubocop-performance', '~> 1.21'
|
|
22
22
|
gem 'rubocop-rake', '~> 0.6'
|
|
23
|
-
gem 'rubocop-rspec', '~>
|
|
23
|
+
gem 'rubocop-rspec', '~> 3.0'
|
|
24
24
|
gem 'timecop', '~> 0.9'
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
sidekiq-prometheus-exporter (0.5.0)
|
|
5
|
+
rack (>= 1.6.0)
|
|
6
|
+
sidekiq (>= 4.1.0)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
appraisal (2.5.0)
|
|
12
|
+
bundler
|
|
13
|
+
rake
|
|
14
|
+
thor (>= 0.14.0)
|
|
15
|
+
ast (2.4.3)
|
|
16
|
+
byebug (12.0.0)
|
|
17
|
+
cgi (0.5.1)
|
|
18
|
+
coderay (1.1.3)
|
|
19
|
+
concurrent-ruby (1.3.8)
|
|
20
|
+
connection_pool (2.4.1)
|
|
21
|
+
date (3.5.1)
|
|
22
|
+
diff-lcs (1.5.1)
|
|
23
|
+
erb (6.0.4)
|
|
24
|
+
io-console (0.8.2)
|
|
25
|
+
irb (1.18.0)
|
|
26
|
+
pp (>= 0.6.0)
|
|
27
|
+
prism (>= 1.3.0)
|
|
28
|
+
rdoc (>= 4.0.0)
|
|
29
|
+
reline (>= 0.4.2)
|
|
30
|
+
json (2.19.9)
|
|
31
|
+
language_server-protocol (3.17.0.5)
|
|
32
|
+
lint_roller (1.1.0)
|
|
33
|
+
logger (1.7.0)
|
|
34
|
+
method_source (1.1.0)
|
|
35
|
+
ostruct (0.6.3)
|
|
36
|
+
parallel (2.1.0)
|
|
37
|
+
parser (3.3.11.1)
|
|
38
|
+
ast (~> 2.4.1)
|
|
39
|
+
racc
|
|
40
|
+
pp (0.6.3)
|
|
41
|
+
prettyprint
|
|
42
|
+
prettyprint (0.2.0)
|
|
43
|
+
prism (1.9.0)
|
|
44
|
+
pry (0.15.2)
|
|
45
|
+
coderay (~> 1.1)
|
|
46
|
+
method_source (~> 1.0)
|
|
47
|
+
pry-byebug (3.11.0)
|
|
48
|
+
byebug (~> 12.0)
|
|
49
|
+
pry (>= 0.13, < 0.16)
|
|
50
|
+
psych (5.3.1)
|
|
51
|
+
date
|
|
52
|
+
stringio
|
|
53
|
+
racc (1.8.1)
|
|
54
|
+
rack (2.2.26)
|
|
55
|
+
rack-test (1.1.0)
|
|
56
|
+
rack (>= 1.0, < 3)
|
|
57
|
+
rainbow (3.1.1)
|
|
58
|
+
rake (13.1.0)
|
|
59
|
+
rdoc (7.2.0)
|
|
60
|
+
erb
|
|
61
|
+
psych (>= 4.0.0)
|
|
62
|
+
tsort
|
|
63
|
+
readline-ext (0.2.0)
|
|
64
|
+
redis-client (0.21.1)
|
|
65
|
+
connection_pool
|
|
66
|
+
regexp_parser (2.12.0)
|
|
67
|
+
reline (0.6.3)
|
|
68
|
+
io-console (~> 0.5)
|
|
69
|
+
rspec (3.13.0)
|
|
70
|
+
rspec-core (~> 3.13.0)
|
|
71
|
+
rspec-expectations (~> 3.13.0)
|
|
72
|
+
rspec-mocks (~> 3.13.0)
|
|
73
|
+
rspec-core (3.13.0)
|
|
74
|
+
rspec-support (~> 3.13.0)
|
|
75
|
+
rspec-expectations (3.13.0)
|
|
76
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
77
|
+
rspec-support (~> 3.13.0)
|
|
78
|
+
rspec-mocks (3.13.0)
|
|
79
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
80
|
+
rspec-support (~> 3.13.0)
|
|
81
|
+
rspec-support (3.13.1)
|
|
82
|
+
rubocop (1.87.0)
|
|
83
|
+
json (~> 2.3)
|
|
84
|
+
language_server-protocol (~> 3.17.0.2)
|
|
85
|
+
lint_roller (~> 1.1.0)
|
|
86
|
+
parallel (>= 1.10)
|
|
87
|
+
parser (>= 3.3.0.2)
|
|
88
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
89
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
90
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
91
|
+
ruby-progressbar (~> 1.7)
|
|
92
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
93
|
+
rubocop-ast (1.49.1)
|
|
94
|
+
parser (>= 3.3.7.2)
|
|
95
|
+
prism (~> 1.7)
|
|
96
|
+
rubocop-performance (1.26.1)
|
|
97
|
+
lint_roller (~> 1.1)
|
|
98
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
99
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
100
|
+
rubocop-rake (0.7.1)
|
|
101
|
+
lint_roller (~> 1.1)
|
|
102
|
+
rubocop (>= 1.72.1)
|
|
103
|
+
rubocop-rspec (3.10.1)
|
|
104
|
+
lint_roller (~> 1.1)
|
|
105
|
+
regexp_parser (>= 2.0)
|
|
106
|
+
rubocop (~> 1.86, >= 1.86.2)
|
|
107
|
+
ruby-progressbar (1.13.0)
|
|
108
|
+
sidekiq (7.2.4)
|
|
109
|
+
concurrent-ruby (< 2)
|
|
110
|
+
connection_pool (>= 2.3.0)
|
|
111
|
+
rack (>= 2.2.4)
|
|
112
|
+
redis-client (>= 0.19.0)
|
|
113
|
+
stringio (3.2.0)
|
|
114
|
+
thor (1.3.1)
|
|
115
|
+
timecop (0.9.8)
|
|
116
|
+
tsort (0.2.0)
|
|
117
|
+
unicode-display_width (3.2.0)
|
|
118
|
+
unicode-emoji (~> 4.1)
|
|
119
|
+
unicode-emoji (4.2.0)
|
|
120
|
+
|
|
121
|
+
PLATFORMS
|
|
122
|
+
ruby
|
|
123
|
+
x86_64-darwin-23
|
|
124
|
+
|
|
125
|
+
DEPENDENCIES
|
|
126
|
+
appraisal (~> 2.2)
|
|
127
|
+
bundler (~> 2.1)
|
|
128
|
+
cgi (~> 0.5)
|
|
129
|
+
irb (~> 1.16)
|
|
130
|
+
logger (~> 1.7)
|
|
131
|
+
ostruct (~> 0.6)
|
|
132
|
+
pry (~> 0.15)
|
|
133
|
+
pry-byebug (~> 3.6)
|
|
134
|
+
rack-test (>= 1.1)
|
|
135
|
+
rake (~> 13.0)
|
|
136
|
+
readline-ext (~> 0.2)
|
|
137
|
+
rspec (~> 3.0)
|
|
138
|
+
rubocop (~> 1.75)
|
|
139
|
+
rubocop-performance (~> 1.21)
|
|
140
|
+
rubocop-rake (~> 0.6)
|
|
141
|
+
rubocop-rspec (~> 3.0)
|
|
142
|
+
sidekiq-prometheus-exporter!
|
|
143
|
+
timecop (~> 0.9)
|
|
144
|
+
|
|
145
|
+
BUNDLED WITH
|
|
146
|
+
2.5.7
|
data/README.md
CHANGED
|
@@ -42,6 +42,7 @@ _(starting Sidekiq `v4.1.0`)_
|
|
|
42
42
|
| sidekiq_dead_jobs | gauge | The number of jobs being dead |
|
|
43
43
|
| sidekiq_queue_latency_seconds | gauge | The number of seconds between oldest job being pushed to the queue and current time (labels: `name`) |
|
|
44
44
|
| sidekiq_queue_max_processing_time_seconds | gauge | The number of seconds between oldest job of the queue being executed and current time (labels: `name`) |
|
|
45
|
+
| sidekiq_job_max_processing_time_seconds | gauge | The number of seconds between oldest job of queue and class being executed and now (labels: `queue`, `class`) |
|
|
45
46
|
| sidekiq_queue_enqueued_jobs | gauge | The number of enqueued jobs in the queue (labels: `name`) |
|
|
46
47
|
| sidekiq_queue_workers | gauge | The number of workers serving the queue (labels: `name`) |
|
|
47
48
|
| sidekiq_queue_processes | gauge | The number of processes serving the queue (labels: `name`) |
|
|
@@ -26,6 +26,7 @@ module Sidekiq
|
|
|
26
26
|
:total_workers, :by_queue, :by_host, :leader_lifetime, keyword_init: true
|
|
27
27
|
)
|
|
28
28
|
JobStats = Struct.new(:processed, :failed, :execution_time, keyword_init: true)
|
|
29
|
+
ProcessingTimeStats = Struct.new(:max, :max_by_class, keyword_init: true)
|
|
29
30
|
|
|
30
31
|
def self.available?
|
|
31
32
|
true
|
|
@@ -121,23 +122,38 @@ module Sidekiq
|
|
|
121
122
|
|
|
122
123
|
now = Time.now.to_i
|
|
123
124
|
|
|
124
|
-
Sidekiq::Workers.new
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
Sidekiq::Workers.new.each_with_object({}) do |(_, _, work), stats|
|
|
126
|
+
queue = work['queue']
|
|
127
|
+
klass = work_class(work)
|
|
128
|
+
time = now - work['run_at']
|
|
129
|
+
|
|
130
|
+
stats[queue] ||= ProcessingTimeStats.new(max: time, max_by_class: {})
|
|
131
|
+
stats[queue].max = time if stats[queue].max < time
|
|
132
|
+
stats[queue].max_by_class[klass] = time if stats[queue].max_by_class.fetch(klass, time) <= time
|
|
133
|
+
end
|
|
130
134
|
end
|
|
131
135
|
|
|
132
136
|
# TODO: Internally Sidekiq::Work stores `run_at` as a timestamp.
|
|
133
137
|
# It would be great to use it instead of invoking `Time.at` call.
|
|
134
138
|
# See: https://github.com/sidekiq/sidekiq/blob/v8.0.0/lib/sidekiq/api.rb#L1253-L1255
|
|
135
139
|
def new_max_processing_times
|
|
136
|
-
now = Time.now
|
|
140
|
+
now = Time.now.to_i
|
|
141
|
+
|
|
142
|
+
Sidekiq::Workers.new.each_with_object({}) do |(_, _, work), stats|
|
|
143
|
+
queue = work.queue
|
|
144
|
+
klass = work.job['wrapped'] || work.job.klass
|
|
145
|
+
time = now - work.run_at.to_i
|
|
146
|
+
|
|
147
|
+
stats[queue] ||= ProcessingTimeStats.new(max: time, max_by_class: {})
|
|
148
|
+
stats[queue].max = time if stats[queue].max < time
|
|
149
|
+
stats[queue].max_by_class[klass] = time if stats[queue].max_by_class.fetch(klass, time) <= time
|
|
150
|
+
end
|
|
151
|
+
end
|
|
137
152
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
153
|
+
def work_class(work)
|
|
154
|
+
payload = work['payload']
|
|
155
|
+
payload = Sidekiq.load_json(payload) if payload.is_a?(String)
|
|
156
|
+
payload['wrapped'] || payload['class']
|
|
141
157
|
end
|
|
142
158
|
end
|
|
143
159
|
end
|
|
@@ -64,8 +64,16 @@ sidekiq_queue_enqueued_jobs{name="<%= queue.name %>"} <%= format('%d', queue.siz
|
|
|
64
64
|
|
|
65
65
|
# HELP sidekiq_queue_max_processing_time_seconds The number of seconds between oldest job of the queue being executed and current time.
|
|
66
66
|
# TYPE sidekiq_queue_max_processing_time_seconds gauge
|
|
67
|
-
<% @max_processing_times.each do |queue,
|
|
68
|
-
sidekiq_queue_max_processing_time_seconds{name="<%= queue %>"} <%= format('%i',
|
|
67
|
+
<% @max_processing_times.each do |queue, stats| %>
|
|
68
|
+
sidekiq_queue_max_processing_time_seconds{name="<%= queue %>"} <%= format('%i', stats.max) %>
|
|
69
|
+
<% end %>
|
|
70
|
+
|
|
71
|
+
# HELP sidekiq_job_max_processing_time_seconds The number of seconds between oldest job of the queue and class being executed and current time.
|
|
72
|
+
# TYPE sidekiq_job_max_processing_time_seconds gauge
|
|
73
|
+
<% @max_processing_times.each do |queue, stats| %>
|
|
74
|
+
<% stats.max_by_class.each do |klass, time| %>
|
|
75
|
+
sidekiq_job_max_processing_time_seconds{queue="<%= queue %>",class="<%= klass %>"} <%= format('%i', time) %>
|
|
76
|
+
<% end %>
|
|
69
77
|
<% end %>
|
|
70
78
|
|
|
71
79
|
# HELP sidekiq_queue_workers The number of workers serving the queue.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sidekiq-prometheus-exporter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sergey Fedorov
|
|
@@ -50,6 +50,7 @@ files:
|
|
|
50
50
|
- Appraisals
|
|
51
51
|
- CLAUDE.md
|
|
52
52
|
- Gemfile
|
|
53
|
+
- Gemfile.lock
|
|
53
54
|
- LICENSE
|
|
54
55
|
- README.md
|
|
55
56
|
- Rakefile
|
|
@@ -85,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
85
86
|
- !ruby/object:Gem::Version
|
|
86
87
|
version: '0'
|
|
87
88
|
requirements: []
|
|
88
|
-
rubygems_version:
|
|
89
|
+
rubygems_version: 4.0.20
|
|
89
90
|
specification_version: 4
|
|
90
91
|
summary: Prometheus exporter for the Sidekiq
|
|
91
92
|
test_files: []
|