sidekiq-prometheus-exporter 0.3.1 → 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 +1 -1
- data/.rubocop.yml +12 -2
- data/CLAUDE.md +24 -0
- data/Gemfile +4 -4
- data/Gemfile.lock +146 -0
- data/README.md +26 -21
- data/Rakefile +44 -3
- data/lib/sidekiq/prometheus/exporter/exporters.rb +1 -1
- data/lib/sidekiq/prometheus/exporter/standard.rb +44 -10
- data/lib/sidekiq/prometheus/exporter/templates/standard.erb +30 -2
- data/lib/sidekiq/prometheus/exporter/version.rb +1 -1
- metadata +4 -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/CLAUDE.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
Ruby gem + Docker image + Helm chart. Gem is the core product, Docker wraps it as standalone Rack app, Helm deploys the Docker image to Kubernetes.
|
|
4
|
+
|
|
5
|
+
## Gem
|
|
6
|
+
|
|
7
|
+
Rack app that scrapes Sidekiq internals and renders Prometheus text format via ERB templates.
|
|
8
|
+
|
|
9
|
+
- Entry point: `lib/sidekiq/prometheus/exporter.rb` — Rack `call` interface, also mounts into Sidekiq::Web
|
|
10
|
+
- Exporters: standard (always on), cron (sidekiq-cron), scheduler (sidekiq-scheduler) — auto-detected via `available?`
|
|
11
|
+
- Metrics output: ERB templates in `lib/sidekiq/prometheus/exporter/templates/`
|
|
12
|
+
- Multi-version support: Appraisal gemfiles for Sidekiq 4.x through 8.x+latest, Rakefile picks spec directory by Sidekiq version
|
|
13
|
+
|
|
14
|
+
## Versioning
|
|
15
|
+
|
|
16
|
+
- `VERSION` in `lib/sidekiq/prometheus/exporter/version.rb` — gem, Docker base, Helm appVersion
|
|
17
|
+
- `DOCKER_PATCH_VERSION` — bumped for Docker-only changes, resets on VERSION bump
|
|
18
|
+
- Helm chart `version` uses `-X` suffix for chart-only changes (e.g. `0.3.1-1`)
|
|
19
|
+
|
|
20
|
+
## Commands
|
|
21
|
+
|
|
22
|
+
- `bundle exec rake spec` — run specs (auto-selects spec dir by Sidekiq version)
|
|
23
|
+
- `bundle exec rake docker:release` — build+push multi-arch Docker image
|
|
24
|
+
- `bundle exec rake helm:generate` — package chart and regenerate index.yaml
|
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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
[](https://codeclimate.com/github/Strech/sidekiq-prometheus-exporter/maintainability)
|
|
3
3
|
|
|
4
4
|
[Sidekiq Enterprise]: https://sidekiq.org/products/enterprise.html
|
|
5
|
+
[Sidekiq v6.5.2]: https://github.com/sidekiq/sidekiq/releases/tag/v6.5.2
|
|
5
6
|
|
|
6
7
|
# Sidekiq Prometheus Exporter
|
|
7
8
|
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
|
|
12
13
|

|
|
13
14
|
|
|
14
|
-
Open [dashboard example file](/examples/sidekiq-dashboard.grafana-
|
|
15
|
+
Open [dashboard example file](/examples/sidekiq-dashboard.grafana-11.json) (grafana 11), then open `https://<your grafana-url>/dashboard/import` and paste the content of the file.
|
|
15
16
|
|
|
16
17
|
---
|
|
17
18
|
|
|
@@ -26,26 +27,30 @@ _(starting Sidekiq `v4.1.0`)_
|
|
|
26
27
|
|
|
27
28
|
## Standard
|
|
28
29
|
|
|
29
|
-
| Name | Type | Description
|
|
30
|
-
| ----------------------------------------- | ------- |
|
|
31
|
-
| sidekiq_processed_jobs_total | counter | The total number of processed jobs
|
|
32
|
-
| sidekiq_failed_jobs_total | counter | The total number of failed jobs
|
|
33
|
-
| sidekiq_workers | gauge | The number of workers across all the processes
|
|
34
|
-
| sidekiq_processes | gauge | The number of processes
|
|
35
|
-
| sidekiq_host_processes | gauge | The number of processes running on the host (labels: `host`, `quiet`)
|
|
36
|
-
| sidekiq_host_processes_memory_usage_bytes | gauge | The amount of real memory (resident set) used by the processes running on the host (labels: `host`)
|
|
37
|
-
| sidekiq_busy_workers | gauge | The number of workers performing the job
|
|
38
|
-
| sidekiq_enqueued_jobs | gauge | The number of enqueued jobs
|
|
39
|
-
| sidekiq_scheduled_jobs | gauge | The number of jobs scheduled for a future execution
|
|
40
|
-
| sidekiq_retry_jobs | gauge | The number of jobs scheduled for the next try
|
|
41
|
-
| sidekiq_dead_jobs | gauge | The number of jobs being dead
|
|
42
|
-
| sidekiq_queue_latency_seconds | gauge | The number of seconds between oldest job being pushed to the queue and current time (labels: `name`)
|
|
43
|
-
| sidekiq_queue_max_processing_time_seconds | gauge | The number of seconds between oldest job of the queue being executed and current time (labels: `name`)
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
30
|
+
| Name | Type | Description |
|
|
31
|
+
| ----------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------- |
|
|
32
|
+
| sidekiq_processed_jobs_total | counter | The total number of processed jobs |
|
|
33
|
+
| sidekiq_failed_jobs_total | counter | The total number of failed jobs |
|
|
34
|
+
| sidekiq_workers | gauge | The number of workers across all the processes |
|
|
35
|
+
| sidekiq_processes | gauge | The number of processes |
|
|
36
|
+
| sidekiq_host_processes | gauge | The number of processes running on the host (labels: `host`, `quiet`) |
|
|
37
|
+
| sidekiq_host_processes_memory_usage_bytes | gauge | The amount of real memory (resident set) used by the processes running on the host (labels: `host`) |
|
|
38
|
+
| sidekiq_busy_workers | gauge | The number of workers performing the job |
|
|
39
|
+
| sidekiq_enqueued_jobs | gauge | The number of enqueued jobs |
|
|
40
|
+
| sidekiq_scheduled_jobs | gauge | The number of jobs scheduled for a future execution |
|
|
41
|
+
| sidekiq_retry_jobs | gauge | The number of jobs scheduled for the next try |
|
|
42
|
+
| sidekiq_dead_jobs | gauge | The number of jobs being dead |
|
|
43
|
+
| sidekiq_queue_latency_seconds | gauge | The number of seconds between oldest job being pushed to the queue and current time (labels: `name`) |
|
|
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`) |
|
|
46
|
+
| sidekiq_queue_enqueued_jobs | gauge | The number of enqueued jobs in the queue (labels: `name`) |
|
|
47
|
+
| sidekiq_queue_workers | gauge | The number of workers serving the queue (labels: `name`) |
|
|
48
|
+
| sidekiq_queue_processes | gauge | The number of processes serving the queue (labels: `name`) |
|
|
49
|
+
| sidekiq_queue_busy_workers | gauge | The number of workers performing the job for the queue (labels: `name`) |
|
|
50
|
+
| sidekiq_leader_lifetime_seconds | gauge | The number of seconds since cluster leader has been created (only [Sidekiq Enterprise]) |
|
|
51
|
+
| sidekiq_job_processed | gauge | The number of processed jobs per job class over the last hour (labels: `class`, since [Sidekiq v6.5.2]) |
|
|
52
|
+
| sidekiq_job_failed | gauge | The number of failed jobs per job class over the last hour (labels: `class`, since [Sidekiq v6.5.2]) |
|
|
53
|
+
| sidekiq_job_execution_time_seconds | gauge | The total execution time in seconds per job class over the last hour (labels: `class`, since [Sidekiq v6.5.2]) |
|
|
49
54
|
|
|
50
55
|
<details>
|
|
51
56
|
<summary>Click to expand for all available contribs</summary>
|
data/Rakefile
CHANGED
|
@@ -22,6 +22,7 @@ task default: :spec
|
|
|
22
22
|
|
|
23
23
|
require 'English'
|
|
24
24
|
require 'fileutils'
|
|
25
|
+
require 'yaml'
|
|
25
26
|
require_relative 'lib/sidekiq/prometheus/exporter/version'
|
|
26
27
|
|
|
27
28
|
VERSION = Sidekiq::Prometheus::Exporter::VERSION
|
|
@@ -78,10 +79,50 @@ namespace :docker do
|
|
|
78
79
|
end
|
|
79
80
|
|
|
80
81
|
namespace :helm do
|
|
82
|
+
desc "Release Helm chart: package, update gh-pages index, attach archive to GitHub release v#{VERSION}"
|
|
83
|
+
task :release, %i(version) do |_, args|
|
|
84
|
+
args.with_defaults(version: VERSION)
|
|
85
|
+
|
|
86
|
+
system('git diff-index --quiet HEAD --') or abort('Working tree has uncommitted changes')
|
|
87
|
+
|
|
88
|
+
current_branch = execute('git branch --show-current').strip
|
|
89
|
+
archive_dir_suffix = Time.now.to_i
|
|
90
|
+
archive_dir_path = File.expand_path("./tmp/archive-#{archive_dir_suffix}")
|
|
91
|
+
chart_version = YAML.load_file(
|
|
92
|
+
File.expand_path('./helm/sidekiq-prometheus-exporter/Chart.yaml')
|
|
93
|
+
).fetch('version')
|
|
94
|
+
|
|
95
|
+
Rake::Task['helm:generate'].invoke(args.version, archive_dir_suffix)
|
|
96
|
+
|
|
97
|
+
tgz = Dir.glob(File.join(archive_dir_path, '*.tgz')).first
|
|
98
|
+
abort 'No .tgz file found' unless tgz
|
|
99
|
+
|
|
100
|
+
index = File.join(archive_dir_path, 'index.yaml')
|
|
101
|
+
|
|
102
|
+
begin
|
|
103
|
+
execute('git checkout gh-pages')
|
|
104
|
+
FileUtils.cp(index, './index.yaml')
|
|
105
|
+
|
|
106
|
+
if execute('git diff index.yaml').strip.empty?
|
|
107
|
+
puts 'index.yaml unchanged, skipping commit'
|
|
108
|
+
else
|
|
109
|
+
execute('git add index.yaml')
|
|
110
|
+
execute("git commit -m 'Bump Helm chart version to #{chart_version}'")
|
|
111
|
+
execute('git push origin gh-pages')
|
|
112
|
+
puts "gh-pages updated with chart version #{chart_version}"
|
|
113
|
+
end
|
|
114
|
+
ensure
|
|
115
|
+
execute("git checkout #{current_branch}")
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
execute("gh release upload v#{VERSION} #{tgz}")
|
|
119
|
+
puts "#{File.basename(tgz)} attached to release v#{VERSION}"
|
|
120
|
+
end
|
|
121
|
+
|
|
81
122
|
desc 'Generate new Helm repo index'
|
|
82
|
-
task :generate, %i(version) do |_, args|
|
|
83
|
-
args.with_defaults(version: docker_version)
|
|
84
|
-
archive_dir = File.expand_path("./tmp/archive-#{
|
|
123
|
+
task :generate, %i(version suffix) do |_, args|
|
|
124
|
+
args.with_defaults(version: docker_version, suffix: Time.now.to_i)
|
|
125
|
+
archive_dir = File.expand_path("./tmp/archive-#{args.suffix}")
|
|
85
126
|
|
|
86
127
|
Rake::Task['helm:package'].invoke(archive_dir)
|
|
87
128
|
Rake::Task['helm:index'].invoke(archive_dir, args.version)
|
|
@@ -8,7 +8,9 @@ module Sidekiq
|
|
|
8
8
|
module Exporter
|
|
9
9
|
class Standard
|
|
10
10
|
UNKNOWN_IDENTITY = 'unknown-identity'.freeze
|
|
11
|
+
MINUTES_IN_HOUR = 60
|
|
11
12
|
BYTES_IN_KILOBYTE = 1024
|
|
13
|
+
MILLISECONDS_IN_SECOND = 1000
|
|
12
14
|
OMIT_NEWLINES_MODE = '<>'.freeze
|
|
13
15
|
TEMPLATE = ERB.new(
|
|
14
16
|
File.read(File.expand_path('templates/standard.erb', __dir__)),
|
|
@@ -23,6 +25,8 @@ module Sidekiq
|
|
|
23
25
|
WorkersStats = Struct.new(
|
|
24
26
|
:total_workers, :by_queue, :by_host, :leader_lifetime, keyword_init: true
|
|
25
27
|
)
|
|
28
|
+
JobStats = Struct.new(:processed, :failed, :execution_time, keyword_init: true)
|
|
29
|
+
ProcessingTimeStats = Struct.new(:max, :max_by_class, keyword_init: true)
|
|
26
30
|
|
|
27
31
|
def self.available?
|
|
28
32
|
true
|
|
@@ -33,6 +37,7 @@ module Sidekiq
|
|
|
33
37
|
@show_memory_usage = false
|
|
34
38
|
|
|
35
39
|
@overview_stats = Sidekiq::Stats.new
|
|
40
|
+
@jobs_stats = jobs_stats
|
|
36
41
|
@queues_stats = queues_stats
|
|
37
42
|
@workers_stats = workers_stats
|
|
38
43
|
@max_processing_times = max_processing_times
|
|
@@ -98,28 +103,57 @@ module Sidekiq
|
|
|
98
103
|
kilobytes * BYTES_IN_KILOBYTE
|
|
99
104
|
end
|
|
100
105
|
|
|
106
|
+
# NOTE: available only starting v6.5.2
|
|
107
|
+
def jobs_stats
|
|
108
|
+
return unless defined?(Sidekiq::Metrics::Query)
|
|
109
|
+
|
|
110
|
+
Sidekiq::Metrics::Query.new.top_jobs(minutes: MINUTES_IN_HOUR)
|
|
111
|
+
.job_results.transform_values! do |result|
|
|
112
|
+
JobStats.new(
|
|
113
|
+
processed: result.totals['p'],
|
|
114
|
+
failed: result.totals['f'],
|
|
115
|
+
execution_time: result.totals['ms'].fdiv(MILLISECONDS_IN_SECOND)
|
|
116
|
+
)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
101
120
|
def max_processing_times
|
|
102
121
|
return new_max_processing_times if Sidekiq.const_defined?(:Work)
|
|
103
122
|
|
|
104
123
|
now = Time.now.to_i
|
|
105
124
|
|
|
106
|
-
Sidekiq::Workers.new
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
|
112
134
|
end
|
|
113
135
|
|
|
114
136
|
# TODO: Internally Sidekiq::Work stores `run_at` as a timestamp.
|
|
115
137
|
# It would be great to use it instead of invoking `Time.at` call.
|
|
116
138
|
# See: https://github.com/sidekiq/sidekiq/blob/v8.0.0/lib/sidekiq/api.rb#L1253-L1255
|
|
117
139
|
def new_max_processing_times
|
|
118
|
-
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
|
|
119
152
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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']
|
|
123
157
|
end
|
|
124
158
|
end
|
|
125
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.
|
|
@@ -91,3 +99,23 @@ sidekiq_queue_busy_workers{name="<%= queue %>"} <%= format('%i', stats.busy_work
|
|
|
91
99
|
# TYPE sidekiq_leader_lifetime_seconds gauge
|
|
92
100
|
sidekiq_leader_lifetime_seconds <%= format('%d', @workers_stats.leader_lifetime) %>
|
|
93
101
|
<% end %>
|
|
102
|
+
<% if @jobs_stats %>
|
|
103
|
+
|
|
104
|
+
# HELP sidekiq_job_processed The number of processed jobs per job class over the last hour.
|
|
105
|
+
# TYPE sidekiq_job_processed gauge
|
|
106
|
+
<% @jobs_stats.each do |klass, stats| %>
|
|
107
|
+
sidekiq_job_processed{class="<%= klass %>"} <%= format('%d', stats.processed) %>
|
|
108
|
+
<% end %>
|
|
109
|
+
|
|
110
|
+
# HELP sidekiq_job_failed The number of failed jobs per job class over the last hour.
|
|
111
|
+
# TYPE sidekiq_job_failed gauge
|
|
112
|
+
<% @jobs_stats.each do |klass, stats| %>
|
|
113
|
+
sidekiq_job_failed{class="<%= klass %>"} <%= format('%d', stats.failed) %>
|
|
114
|
+
<% end %>
|
|
115
|
+
|
|
116
|
+
# HELP sidekiq_job_execution_time_seconds The total execution time in seconds per job class over the last hour.
|
|
117
|
+
# TYPE sidekiq_job_execution_time_seconds gauge
|
|
118
|
+
<% @jobs_stats.each do |klass, stats| %>
|
|
119
|
+
sidekiq_job_execution_time_seconds{class="<%= klass %>"} <%= format('%.3f', stats.execution_time) %>
|
|
120
|
+
<% end %>
|
|
121
|
+
<% end %>
|
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
|
|
@@ -48,7 +48,9 @@ files:
|
|
|
48
48
|
- ".rspec"
|
|
49
49
|
- ".rubocop.yml"
|
|
50
50
|
- Appraisals
|
|
51
|
+
- CLAUDE.md
|
|
51
52
|
- Gemfile
|
|
53
|
+
- Gemfile.lock
|
|
52
54
|
- LICENSE
|
|
53
55
|
- README.md
|
|
54
56
|
- Rakefile
|
|
@@ -84,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
84
86
|
- !ruby/object:Gem::Version
|
|
85
87
|
version: '0'
|
|
86
88
|
requirements: []
|
|
87
|
-
rubygems_version:
|
|
89
|
+
rubygems_version: 4.0.20
|
|
88
90
|
specification_version: 4
|
|
89
91
|
summary: Prometheus exporter for the Sidekiq
|
|
90
92
|
test_files: []
|