yabeda-sidekiq 0.10.0 → 0.11.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/.github/workflows/lint.yml +2 -2
- data/.github/workflows/{build-release.yml → release.yml} +9 -5
- data/.github/workflows/test.yml +18 -22
- data/.rubocop.yml +13 -1
- data/CHANGELOG.md +11 -0
- data/Gemfile +27 -1
- data/README.md +6 -5
- data/lib/yabeda/sidekiq/config.rb +4 -0
- data/lib/yabeda/sidekiq/version.rb +1 -1
- data/lib/yabeda/sidekiq.rb +22 -22
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad8acaec8b59c1c088c6c924d5bbc777b1c87c346b56389045e4609b3920af11
|
4
|
+
data.tar.gz: 26e87dbce002e1053eb6f5c709a78642b002691cad1f69e7d1d02722dd692790
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 880a85b150e20c3b78a330d7fa9a2ae578d7fba140adaf9d01e8fdae467c57f746607efa601404b9b9f20d8bbf0fb98b560177ef198095fa48176f79ccc5ce10
|
7
|
+
data.tar.gz: 720157c2e892d40ddd776e186055403d79162a8554c36a080003678f1f73d69a9cf924c5ef17bab42235b309506ef620eca80c6311e9af90f83b5c9460585d5a
|
data/.github/workflows/lint.yml
CHANGED
@@ -15,10 +15,10 @@ jobs:
|
|
15
15
|
name: RuboCop
|
16
16
|
runs-on: ubuntu-latest
|
17
17
|
steps:
|
18
|
-
- uses: actions/checkout@
|
18
|
+
- uses: actions/checkout@v4
|
19
19
|
- uses: ruby/setup-ruby@v1
|
20
20
|
with:
|
21
|
-
ruby-version: "3.
|
21
|
+
ruby-version: "3.2"
|
22
22
|
bundler-cache: true
|
23
23
|
- name: Lint Ruby code with RuboCop
|
24
24
|
run: |
|
@@ -1,4 +1,4 @@
|
|
1
|
-
name: Build and release gem
|
1
|
+
name: Build and release gem
|
2
2
|
|
3
3
|
on:
|
4
4
|
push:
|
@@ -8,13 +8,17 @@ on:
|
|
8
8
|
jobs:
|
9
9
|
release:
|
10
10
|
runs-on: ubuntu-latest
|
11
|
+
permissions:
|
12
|
+
contents: write
|
13
|
+
id-token: write
|
14
|
+
packages: write
|
11
15
|
steps:
|
12
|
-
- uses: actions/checkout@
|
16
|
+
- uses: actions/checkout@v4
|
13
17
|
with:
|
14
18
|
fetch-depth: 0 # Fetch current tag as annotated. See https://github.com/actions/checkout/issues/290
|
15
19
|
- uses: ruby/setup-ruby@v1
|
16
20
|
with:
|
17
|
-
ruby-version:
|
21
|
+
ruby-version: "3.3"
|
18
22
|
- name: "Extract data from tag: version, message, body"
|
19
23
|
id: tag
|
20
24
|
run: |
|
@@ -75,8 +79,8 @@ jobs:
|
|
75
79
|
GEM_HOST_API_KEY: Bearer ${{ secrets.GITHUB_TOKEN }}
|
76
80
|
run: |
|
77
81
|
gem push yabeda-sidekiq-${{ steps.tag.outputs.version }}.gem --host https://rubygems.pkg.github.com/${{ github.repository_owner }}
|
82
|
+
- name: Configure RubyGems Credentials
|
83
|
+
uses: rubygems/configure-rubygems-credentials@main
|
78
84
|
- name: Publish to RubyGems
|
79
|
-
env:
|
80
|
-
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"
|
81
85
|
run: |
|
82
86
|
gem push yabeda-sidekiq-${{ steps.tag.outputs.version }}.gem
|
data/.github/workflows/test.yml
CHANGED
@@ -10,7 +10,7 @@ on:
|
|
10
10
|
|
11
11
|
jobs:
|
12
12
|
test:
|
13
|
-
name: 'Ruby ${{ matrix.ruby }}'
|
13
|
+
name: 'Ruby ${{ matrix.ruby }} × Sidekiq v${{ matrix.sidekiq }} × ActiveJob v${{ matrix.activejob }}'
|
14
14
|
# Skip running tests for local pull requests (use push event instead), run only for foreign ones
|
15
15
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
|
16
16
|
runs-on: ubuntu-latest
|
@@ -18,30 +18,26 @@ jobs:
|
|
18
18
|
fail-fast: false
|
19
19
|
matrix:
|
20
20
|
include:
|
21
|
+
- ruby: '3.3'
|
22
|
+
sidekiq: '7'
|
23
|
+
activejob: '7.1'
|
24
|
+
- ruby: '3.2'
|
25
|
+
sidekiq: '7'
|
26
|
+
activejob: '7.0'
|
21
27
|
- ruby: '3.1'
|
28
|
+
sidekiq: '6'
|
29
|
+
activejob: '6.1'
|
22
30
|
- ruby: '3.0'
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
env:
|
29
|
-
CI: true
|
31
|
+
sidekiq: '5'
|
32
|
+
activejob: '6.0'
|
33
|
+
env:
|
34
|
+
SIDEKIQ_VERSION: '${{ matrix.sidekiq }}'
|
35
|
+
ACTIVEJOB_VERSION: '${{ matrix.activejob }}'
|
30
36
|
steps:
|
31
|
-
- uses: actions/checkout@
|
32
|
-
- uses:
|
37
|
+
- uses: actions/checkout@v4
|
38
|
+
- uses: ruby/setup-ruby@v1
|
33
39
|
with:
|
34
|
-
|
35
|
-
|
36
|
-
restore-keys: |
|
37
|
-
bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
|
38
|
-
bundle-${{ matrix.ruby }}-
|
39
|
-
- name: Upgrade Bundler to 2.0 (for older Rubies)
|
40
|
-
run: gem install bundler -v '~> 2.0'
|
41
|
-
- name: Bundle install
|
42
|
-
run: |
|
43
|
-
bundle config path vendor/bundle
|
44
|
-
bundle install
|
45
|
-
bundle update
|
40
|
+
ruby-version: ${{ matrix.ruby }}
|
41
|
+
bundler-cache: true
|
46
42
|
- name: Run RSpec
|
47
43
|
run: bundle exec rspec
|
data/.rubocop.yml
CHANGED
@@ -3,7 +3,7 @@ require:
|
|
3
3
|
- rubocop-rspec
|
4
4
|
|
5
5
|
AllCops:
|
6
|
-
TargetRubyVersion: 2.
|
6
|
+
TargetRubyVersion: 2.5
|
7
7
|
|
8
8
|
Metrics/BlockLength:
|
9
9
|
Enabled: false
|
@@ -65,3 +65,15 @@ Metrics/MethodLength:
|
|
65
65
|
|
66
66
|
Metrics/AbcSize:
|
67
67
|
Max: 17
|
68
|
+
|
69
|
+
Style/SoleNestedConditional:
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
Style/ExplicitBlockArgument:
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
Gemspec/RequiredRubyVersion:
|
76
|
+
Enabled: false
|
77
|
+
|
78
|
+
Metrics/ModuleLength:
|
79
|
+
Max: 200
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
7
7
|
|
8
8
|
## Unreleased
|
9
9
|
|
10
|
+
## 0.11.0 - 2024-02-07
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- `retries_segmented_by_queue` configuration setting to allow segmentation of retry count by queue.
|
15
|
+
|
16
|
+
It is disabled by default as it requires to iterate over all jobs in the retry set and may be very slow if number of retries is huge.
|
17
|
+
|
18
|
+
Pull request [#32](https://github.com/yabeda-rb/yabeda-sidekiq/pull/32) by [@SxDx]
|
19
|
+
|
10
20
|
## 0.10.0 - 2022-10-25
|
11
21
|
|
12
22
|
### Added
|
@@ -119,3 +129,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
119
129
|
[@asusikov]: https://github.com/asusikov "Alexander Susikov"
|
120
130
|
[@mrexox]: https://github.com/mrexox "Valentine Kiselev"
|
121
131
|
[@LukinEgor]: https://github.com/LukinEgor "Egor Lukin"
|
132
|
+
[@SxDx]: https://github.com/SxDx "René Koller"
|
data/Gemfile
CHANGED
@@ -7,10 +7,36 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
7
7
|
# Specify your gem's dependencies in yabeda-sidekiq.gemspec
|
8
8
|
gemspec
|
9
9
|
|
10
|
+
# rubocop:disable Bundler/DuplicatedGem
|
11
|
+
sidekiq_version = ENV.fetch("SIDEKIQ_VERSION", "~> 7.2")
|
12
|
+
case sidekiq_version
|
13
|
+
when "HEAD"
|
14
|
+
gem "sidekiq", git: "https://github.com/sidekiq/sidekiq.git"
|
15
|
+
else
|
16
|
+
sidekiq_version = "~> #{sidekiq_version}.0" if sidekiq_version.match?(/^\d+(?:\.\d+)?$/)
|
17
|
+
gem "sidekiq", sidekiq_version
|
18
|
+
end
|
19
|
+
|
20
|
+
activejob_version = ENV.fetch("ACTIVEJOB_VERSION", "~> 7.1")
|
21
|
+
case activejob_version
|
22
|
+
when "HEAD"
|
23
|
+
git "https://github.com/rails/rails.git" do
|
24
|
+
gem "activejob"
|
25
|
+
gem "activesupport"
|
26
|
+
gem "rails"
|
27
|
+
end
|
28
|
+
else
|
29
|
+
activejob_version = "~> #{activejob_version}.0" if activejob_version.match?(/^\d+\.\d+$/)
|
30
|
+
gem "activejob", activejob_version
|
31
|
+
gem "activesupport", activejob_version
|
32
|
+
end
|
33
|
+
# rubocop:enable Bundler/DuplicatedGem
|
34
|
+
|
10
35
|
group :development, :test do
|
11
36
|
gem "pry"
|
12
37
|
gem "pry-byebug", platform: :mri
|
13
38
|
|
14
|
-
gem "
|
39
|
+
gem "yabeda", github: "yabeda-rb/yabeda", branch: "master" # For RSpec matchers
|
40
|
+
gem "rubocop", "~> 1.0"
|
15
41
|
gem "rubocop-rspec"
|
16
42
|
end
|
data/README.md
CHANGED
@@ -99,14 +99,15 @@ end
|
|
99
99
|
|
100
100
|
Configuration is handled by [anyway_config] gem. With it you can load settings from environment variables (upcased and prefixed with `YABEDA_SIDEKIQ_`), YAML files, and other sources. See [anyway_config] docs for details.
|
101
101
|
|
102
|
-
Config key
|
103
|
-
|
104
|
-
`collect_cluster_metrics`
|
105
|
-
`declare_process_metrics`
|
102
|
+
Config key | Type | Default | Description |
|
103
|
+
---------------------------- | -------- | ------------------------------------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------|
|
104
|
+
`collect_cluster_metrics` | boolean | Enabled in Sidekiq worker processes, disabled otherwise | Defines whether this Ruby process should collect and expose metrics representing state of the whole Sidekiq installation (queues, processes, etc). |
|
105
|
+
`declare_process_metrics` | boolean | Enabled in Sidekiq worker processes, disabled otherwise | Declare metrics that are only tracked inside worker process even outside of them. Useful for multiprocess metric collection. |
|
106
|
+
`retries_segmented_by_queue` | boolean | Disabled | Defines wheter retries are segemented by queue or reported as a single metric |
|
106
107
|
|
107
108
|
# Roadmap (TODO or Help wanted)
|
108
109
|
|
109
|
-
- Implement optional segmentation of
|
110
|
+
- Implement optional segmentation of schedule/dead sets
|
110
111
|
|
111
112
|
It should be disabled by default as it requires to iterate over all jobs in sets and may be very slow on large sets.
|
112
113
|
|
@@ -16,6 +16,10 @@ module Yabeda
|
|
16
16
|
|
17
17
|
# Declare metrics that are only tracked inside worker process even outside them
|
18
18
|
attr_config declare_process_metrics: ::Sidekiq.server?
|
19
|
+
|
20
|
+
# Retries are tracked by default as a single metric. If you want to track them separately for each queue, set this to +true+
|
21
|
+
# Disabled by default because it is quite slow if the retry set is large
|
22
|
+
attr_config retries_segmented_by_queue: false
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
data/lib/yabeda/sidekiq.rb
CHANGED
@@ -49,13 +49,16 @@ module Yabeda
|
|
49
49
|
# Metrics not specific for current Sidekiq process, but representing state of the whole Sidekiq installation (queues, processes, etc)
|
50
50
|
# You can opt-out from collecting these by setting YABEDA_SIDEKIQ_COLLECT_CLUSTER_METRICS to falsy value (+no+ or +false+)
|
51
51
|
if config.collect_cluster_metrics # defaults to +::Sidekiq.server?+
|
52
|
-
|
53
|
-
|
54
|
-
gauge :
|
55
|
-
gauge :
|
56
|
-
|
57
|
-
gauge :
|
58
|
-
gauge :
|
52
|
+
retry_count_tags = config.retries_segmented_by_queue ? %i[queue] : []
|
53
|
+
|
54
|
+
gauge :jobs_waiting_count, tags: %i[queue], aggregation: :most_recent, comment: "The number of jobs waiting to process in sidekiq."
|
55
|
+
gauge :active_workers_count, tags: [], aggregation: :most_recent,
|
56
|
+
comment: "The number of currently running machines with sidekiq workers."
|
57
|
+
gauge :jobs_scheduled_count, tags: [], aggregation: :most_recent, comment: "The number of jobs scheduled for later execution."
|
58
|
+
gauge :jobs_retry_count, tags: retry_count_tags, aggregation: :most_recent, comment: "The number of failed jobs waiting to be retried"
|
59
|
+
gauge :jobs_dead_count, tags: [], aggregation: :most_recent, comment: "The number of jobs exceeded their retry count."
|
60
|
+
gauge :active_processes, tags: [], aggregation: :most_recent, comment: "The number of active Sidekiq worker processes."
|
61
|
+
gauge :queue_latency, tags: %i[queue], aggregation: :most_recent,
|
59
62
|
comment: "The queue latency, the difference in seconds since the oldest job in the queue was enqueued"
|
60
63
|
end
|
61
64
|
|
@@ -73,21 +76,22 @@ module Yabeda
|
|
73
76
|
sidekiq_jobs_scheduled_count.set({}, stats.scheduled_size)
|
74
77
|
sidekiq_jobs_dead_count.set({}, stats.dead_size)
|
75
78
|
sidekiq_active_processes.set({}, stats.processes_size)
|
76
|
-
sidekiq_jobs_retry_count.set({}, stats.retry_size)
|
77
79
|
|
78
80
|
::Sidekiq::Queue.all.each do |queue|
|
79
81
|
sidekiq_queue_latency.set({ queue: queue.name }, queue.latency)
|
80
82
|
end
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
84
|
+
if config.retries_segmented_by_queue
|
85
|
+
retries_by_queues =
|
86
|
+
::Sidekiq::RetrySet.new.each_with_object(Hash.new(0)) do |job, cntr|
|
87
|
+
cntr[job["queue"]] += 1
|
88
|
+
end
|
89
|
+
retries_by_queues.each do |queue, count|
|
90
|
+
sidekiq_jobs_retry_count.set({ queue: queue }, count)
|
91
|
+
end
|
92
|
+
else
|
93
|
+
sidekiq_jobs_retry_count.set({}, stats.retry_size)
|
94
|
+
end
|
91
95
|
end
|
92
96
|
end
|
93
97
|
|
@@ -112,11 +116,7 @@ module Yabeda
|
|
112
116
|
end
|
113
117
|
|
114
118
|
def worker_class(worker, job)
|
115
|
-
|
116
|
-
if worker.is_a?(ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper) || worker == ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper
|
117
|
-
return job["wrapped"].to_s
|
118
|
-
end
|
119
|
-
end
|
119
|
+
worker = job["wrapped"] || worker
|
120
120
|
(worker.is_a?(String) || worker.is_a?(Class) ? worker : worker.class).to_s
|
121
121
|
end
|
122
122
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yabeda-sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Novikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anyway_config
|
@@ -122,8 +122,8 @@ executables: []
|
|
122
122
|
extensions: []
|
123
123
|
extra_rdoc_files: []
|
124
124
|
files:
|
125
|
-
- ".github/workflows/build-release.yml"
|
126
125
|
- ".github/workflows/lint.yml"
|
126
|
+
- ".github/workflows/release.yml"
|
127
127
|
- ".github/workflows/test.yml"
|
128
128
|
- ".gitignore"
|
129
129
|
- ".rspec"
|
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
161
|
- !ruby/object:Gem::Version
|
162
162
|
version: '0'
|
163
163
|
requirements: []
|
164
|
-
rubygems_version: 3.
|
164
|
+
rubygems_version: 3.5.3
|
165
165
|
signing_key:
|
166
166
|
specification_version: 4
|
167
167
|
summary: Extensible Prometheus exporter for monitoring your Sidekiq
|