yabeda-sidekiq 0.11.0 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad8acaec8b59c1c088c6c924d5bbc777b1c87c346b56389045e4609b3920af11
4
- data.tar.gz: 26e87dbce002e1053eb6f5c709a78642b002691cad1f69e7d1d02722dd692790
3
+ metadata.gz: 3a429f27fdff4c0295a99045e54af89fac47d0ed6bcae3e13988c1c1b811e8b0
4
+ data.tar.gz: 6508f78bfc9d19697b688fef975c82de7be3177ee05df1aceea9befc0e271b6f
5
5
  SHA512:
6
- metadata.gz: 880a85b150e20c3b78a330d7fa9a2ae578d7fba140adaf9d01e8fdae467c57f746607efa601404b9b9f20d8bbf0fb98b560177ef198095fa48176f79ccc5ce10
7
- data.tar.gz: 720157c2e892d40ddd776e186055403d79162a8554c36a080003678f1f73d69a9cf924c5ef17bab42235b309506ef620eca80c6311e9af90f83b5c9460585d5a
6
+ metadata.gz: 127a4ffc2ad85ac7f472dc4de218df07be1612b05c145ceb8edc14c14cbb31390e45c1608a676c03bcfa927fe2a1398f7d2855731ee4d42a547388e8f45d975c
7
+ data.tar.gz: 362af4e3b0058f6d8453a0f8fc19ee81ce2963f285a5a82aafbfc4e7f09ae5a73ce5b73ccdfe044b60c83c31a9ce5a9408b9a07852d57c0dd5e51cb671abd642
data/CHANGELOG.md CHANGED
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 0.12.0 - 2024-03-08
11
+
12
+ ### Added
13
+
14
+ - Optional capture of error class for failed jobs counter.
15
+
16
+ Set `label_for_error_class_on_sidekiq_jobs_failed` to `true` to add `error` label to `sidekiq_jobs_failed_total` metric.
17
+
18
+ Pull request [#34](https://github.com/yabeda-rb/yabeda-sidekiq/pull/34) by [@niborg]
19
+
20
+ ### Changed
21
+
22
+ - Stop including development-related files into packaged gem to avoid confusing users or software tools. [@Envek]
23
+
10
24
  ## 0.11.0 - 2024-02-07
11
25
 
12
26
  ### Added
@@ -130,3 +144,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
130
144
  [@mrexox]: https://github.com/mrexox "Valentine Kiselev"
131
145
  [@LukinEgor]: https://github.com/LukinEgor "Egor Lukin"
132
146
  [@SxDx]: https://github.com/SxDx "René Koller"
147
+ [@niborg]: https://github.com/niborg "Nick Knipe"
data/README.md CHANGED
@@ -99,11 +99,12 @@ 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 | 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 |
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 |
107
+ | `label_for_error_class_on_sidekiq_jobs_failed` | boolean | Disabled | Defines whether `error` label should be added to `sidekiq_jobs_failed_total` metric. |
107
108
 
108
109
  # Roadmap (TODO or Help wanted)
109
110
 
@@ -20,6 +20,9 @@ module Yabeda
20
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
21
  # Disabled by default because it is quite slow if the retry set is large
22
22
  attr_config retries_segmented_by_queue: false
23
+
24
+ # If set to true, an `:error` label will be added with name of the error class to all failed jobs
25
+ attr_config label_for_error_class_on_sidekiq_jobs_failed: false
23
26
  end
24
27
  end
25
28
  end
@@ -20,8 +20,10 @@ module Yabeda
20
20
  yield
21
21
  end
22
22
  Yabeda.sidekiq_jobs_success_total.increment(labels)
23
- rescue Exception # rubocop: disable Lint/RescueException
24
- Yabeda.sidekiq_jobs_failed_total.increment(labels)
23
+ rescue Exception => e # rubocop: disable Lint/RescueException
24
+ jobs_failed_labels = labels.dup
25
+ jobs_failed_labels[:error] = e.class.name if Yabeda::Sidekiq.config.label_for_error_class_on_sidekiq_jobs_failed
26
+ Yabeda.sidekiq_jobs_failed_total.increment(jobs_failed_labels)
25
27
  raise
26
28
  ensure
27
29
  Yabeda.sidekiq_job_runtime.measure(labels, elapsed(start))
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Sidekiq
5
- VERSION = "0.11.0"
5
+ VERSION = "0.12.0"
6
6
  end
7
7
  end
@@ -29,9 +29,11 @@ module Yabeda
29
29
  counter :jobs_rerouted_total, tags: %i[from_queue to_queue worker], comment: "A counter of the total number of rerouted jobs sidekiq enqueued."
30
30
 
31
31
  if config.declare_process_metrics # defaults to +::Sidekiq.server?+
32
+ failed_total_tags = config.label_for_error_class_on_sidekiq_jobs_failed ? %i[queue worker error] : %i[queue worker]
33
+
32
34
  counter :jobs_executed_total, tags: %i[queue worker], comment: "A counter of the total number of jobs sidekiq executed."
33
35
  counter :jobs_success_total, tags: %i[queue worker], comment: "A counter of the total number of jobs successfully processed by sidekiq."
34
- counter :jobs_failed_total, tags: %i[queue worker], comment: "A counter of the total number of jobs failed in sidekiq."
36
+ counter :jobs_failed_total, tags: failed_total_tags, comment: "A counter of the total number of jobs failed in sidekiq."
35
37
 
36
38
  gauge :running_job_runtime, tags: %i[queue worker], aggregation: :max, unit: :seconds,
37
39
  comment: "How long currently running jobs are running (useful for detection of hung jobs)"
@@ -15,8 +15,13 @@ Gem::Specification.new do |spec|
15
15
  spec.homepage = "https://github.com/yabeda-rb/yabeda-sidekiq"
16
16
  spec.license = "MIT"
17
17
 
18
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
- f.match(%r{^(test|spec|features)/})
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
21
+ spec.metadata["bug_tracker_uri"] = "#{spec.homepage}/issues"
22
+
23
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
+ f.match(%r{^(\.|bin/|spec/|tmp/|Gemfile|Rakefile|yabeda-sidekiq-logo\.png)})
20
25
  end
21
26
  spec.bindir = "exe"
22
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
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.11.0
4
+ version: 0.12.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: 2024-02-07 00:00:00.000000000 Z
11
+ date: 2024-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anyway_config
@@ -122,30 +122,23 @@ executables: []
122
122
  extensions: []
123
123
  extra_rdoc_files: []
124
124
  files:
125
- - ".github/workflows/lint.yml"
126
- - ".github/workflows/release.yml"
127
- - ".github/workflows/test.yml"
128
- - ".gitignore"
129
- - ".rspec"
130
- - ".rubocop.yml"
131
125
  - CHANGELOG.md
132
- - Gemfile
133
126
  - LICENSE.txt
134
127
  - README.md
135
- - Rakefile
136
- - bin/console
137
- - bin/setup
138
128
  - lib/yabeda/sidekiq.rb
139
129
  - lib/yabeda/sidekiq/client_middleware.rb
140
130
  - lib/yabeda/sidekiq/config.rb
141
131
  - lib/yabeda/sidekiq/server_middleware.rb
142
132
  - lib/yabeda/sidekiq/version.rb
143
- - yabeda-sidekiq-logo.png
144
133
  - yabeda-sidekiq.gemspec
145
134
  homepage: https://github.com/yabeda-rb/yabeda-sidekiq
146
135
  licenses:
147
136
  - MIT
148
- metadata: {}
137
+ metadata:
138
+ homepage_uri: https://github.com/yabeda-rb/yabeda-sidekiq
139
+ source_code_uri: https://github.com/yabeda-rb/yabeda-sidekiq
140
+ changelog_uri: https://github.com/yabeda-rb/yabeda-sidekiq/blob/master/CHANGELOG.md
141
+ bug_tracker_uri: https://github.com/yabeda-rb/yabeda-sidekiq/issues
149
142
  post_install_message:
150
143
  rdoc_options: []
151
144
  require_paths:
@@ -1,25 +0,0 @@
1
- name: Lint
2
-
3
- on:
4
- pull_request:
5
- push:
6
- branches:
7
- - '**'
8
- tags-ignore:
9
- - 'v*'
10
-
11
- jobs:
12
- rubocop:
13
- # Skip running tests for local pull requests (use push event instead), run only for foreign ones
14
- if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
15
- name: RuboCop
16
- runs-on: ubuntu-latest
17
- steps:
18
- - uses: actions/checkout@v4
19
- - uses: ruby/setup-ruby@v1
20
- with:
21
- ruby-version: "3.2"
22
- bundler-cache: true
23
- - name: Lint Ruby code with RuboCop
24
- run: |
25
- bundle exec rubocop
@@ -1,86 +0,0 @@
1
- name: Build and release gem
2
-
3
- on:
4
- push:
5
- tags:
6
- - v*
7
-
8
- jobs:
9
- release:
10
- runs-on: ubuntu-latest
11
- permissions:
12
- contents: write
13
- id-token: write
14
- packages: write
15
- steps:
16
- - uses: actions/checkout@v4
17
- with:
18
- fetch-depth: 0 # Fetch current tag as annotated. See https://github.com/actions/checkout/issues/290
19
- - uses: ruby/setup-ruby@v1
20
- with:
21
- ruby-version: "3.3"
22
- - name: "Extract data from tag: version, message, body"
23
- id: tag
24
- run: |
25
- git fetch --tags --force # Really fetch annotated tag. See https://github.com/actions/checkout/issues/290#issuecomment-680260080
26
- echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
27
- echo ::set-output name=subject::$(git for-each-ref $GITHUB_REF --format='%(contents:subject)')
28
- BODY="$(git for-each-ref $GITHUB_REF --format='%(contents:body)')"
29
- # Extract changelog entries between this and previous version headers
30
- escaped_version=$(echo ${GITHUB_REF#refs/tags/v} | sed -e 's/[]\/$*.^[]/\\&/g')
31
- changelog=$(awk "BEGIN{inrelease=0} /## ${escaped_version}/{inrelease=1;next} /## [0-9]+\.[0-9]+\.[0-9]+/{inrelease=0;exit} {if (inrelease) print}" CHANGELOG.md)
32
- # Multiline body for release. See https://github.community/t/set-output-truncates-multiline-strings/16852/5
33
- BODY="${BODY}"$'\n'"${changelog}"
34
- BODY="${BODY//'%'/'%25'}"
35
- BODY="${BODY//$'\n'/'%0A'}"
36
- BODY="${BODY//$'\r'/'%0D'}"
37
- echo "::set-output name=body::$BODY"
38
- # Add pre-release option if tag name has any suffix after vMAJOR.MINOR.PATCH
39
- if [[ ${GITHUB_REF#refs/tags/} =~ ^v[0-9]+\.[0-9]+\.[0-9]+.+ ]]; then
40
- echo ::set-output name=prerelease::true
41
- fi
42
- - name: Build gem
43
- run: gem build
44
- - name: Calculate checksums
45
- run: sha256sum yabeda-sidekiq-${{ steps.tag.outputs.version }}.gem > SHA256SUM
46
- - name: Check version
47
- run: ls -l yabeda-sidekiq-${{ steps.tag.outputs.version }}.gem
48
- - name: Create Release
49
- id: create_release
50
- uses: actions/create-release@v1
51
- env:
52
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53
- with:
54
- tag_name: ${{ github.ref }}
55
- release_name: ${{ steps.tag.outputs.subject }}
56
- body: ${{ steps.tag.outputs.body }}
57
- draft: false
58
- prerelease: ${{ steps.tag.outputs.prerelease }}
59
- - name: Upload built gem as release asset
60
- uses: actions/upload-release-asset@v1
61
- env:
62
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63
- with:
64
- upload_url: ${{ steps.create_release.outputs.upload_url }}
65
- asset_path: yabeda-sidekiq-${{ steps.tag.outputs.version }}.gem
66
- asset_name: yabeda-sidekiq-${{ steps.tag.outputs.version }}.gem
67
- asset_content_type: application/x-tar
68
- - name: Upload checksums as release asset
69
- uses: actions/upload-release-asset@v1
70
- env:
71
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72
- with:
73
- upload_url: ${{ steps.create_release.outputs.upload_url }}
74
- asset_path: SHA256SUM
75
- asset_name: SHA256SUM
76
- asset_content_type: text/plain
77
- - name: Publish to GitHub packages
78
- env:
79
- GEM_HOST_API_KEY: Bearer ${{ secrets.GITHUB_TOKEN }}
80
- run: |
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
84
- - name: Publish to RubyGems
85
- run: |
86
- gem push yabeda-sidekiq-${{ steps.tag.outputs.version }}.gem
@@ -1,43 +0,0 @@
1
- name: Tests
2
-
3
- on:
4
- pull_request:
5
- push:
6
- branches:
7
- - '**'
8
- tags-ignore:
9
- - 'v*'
10
-
11
- jobs:
12
- test:
13
- name: 'Ruby ${{ matrix.ruby }} × Sidekiq v${{ matrix.sidekiq }} × ActiveJob v${{ matrix.activejob }}'
14
- # Skip running tests for local pull requests (use push event instead), run only for foreign ones
15
- if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
16
- runs-on: ubuntu-latest
17
- strategy:
18
- fail-fast: false
19
- matrix:
20
- include:
21
- - ruby: '3.3'
22
- sidekiq: '7'
23
- activejob: '7.1'
24
- - ruby: '3.2'
25
- sidekiq: '7'
26
- activejob: '7.0'
27
- - ruby: '3.1'
28
- sidekiq: '6'
29
- activejob: '6.1'
30
- - ruby: '3.0'
31
- sidekiq: '5'
32
- activejob: '6.0'
33
- env:
34
- SIDEKIQ_VERSION: '${{ matrix.sidekiq }}'
35
- ACTIVEJOB_VERSION: '${{ matrix.activejob }}'
36
- steps:
37
- - uses: actions/checkout@v4
38
- - uses: ruby/setup-ruby@v1
39
- with:
40
- ruby-version: ${{ matrix.ruby }}
41
- bundler-cache: true
42
- - name: Run RSpec
43
- run: bundle exec rspec
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
10
-
11
- # rspec failure tracking
12
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,79 +0,0 @@
1
- ---
2
- require:
3
- - rubocop-rspec
4
-
5
- AllCops:
6
- TargetRubyVersion: 2.5
7
-
8
- Metrics/BlockLength:
9
- Enabled: false
10
- Exclude:
11
- - "Gemfile"
12
- - "spec/**/*"
13
-
14
- Layout/LineLength:
15
- Max: 160
16
-
17
- Style/StringLiterals:
18
- EnforcedStyle: double_quotes
19
-
20
- # Allow to use let!
21
- RSpec/LetSetup:
22
- Enabled: false
23
-
24
- RSpec/MultipleExpectations:
25
- Enabled: false
26
-
27
- Bundler/OrderedGems:
28
- Enabled: false
29
-
30
- Style/TrailingCommaInArguments:
31
- Description: 'Checks for trailing comma in argument lists.'
32
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-params-comma'
33
- Enabled: true
34
- EnforcedStyleForMultiline: consistent_comma
35
-
36
- Style/TrailingCommaInArrayLiteral:
37
- Description: 'Checks for trailing comma in array literals.'
38
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
39
- Enabled: true
40
- EnforcedStyleForMultiline: consistent_comma
41
-
42
- Style/TrailingCommaInHashLiteral:
43
- Description: 'Checks for trailing comma in hash literals.'
44
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
45
- Enabled: true
46
- EnforcedStyleForMultiline: consistent_comma
47
-
48
- Style/HashEachMethods:
49
- Enabled: true
50
-
51
- Style/HashTransformKeys:
52
- Enabled: true
53
-
54
- Style/HashTransformValues:
55
- Enabled: true
56
-
57
- RSpec/ExampleLength:
58
- Enabled: false
59
-
60
- Style/Documentation:
61
- Enabled: false
62
-
63
- Metrics/MethodLength:
64
- Max: 15
65
-
66
- Metrics/AbcSize:
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/Gemfile DELETED
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
-
7
- # Specify your gem's dependencies in yabeda-sidekiq.gemspec
8
- gemspec
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
-
35
- group :development, :test do
36
- gem "pry"
37
- gem "pry-byebug", platform: :mri
38
-
39
- gem "yabeda", github: "yabeda-rb/yabeda", branch: "master" # For RSpec matchers
40
- gem "rubocop", "~> 1.0"
41
- gem "rubocop-rspec"
42
- end
data/Rakefile DELETED
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
- require "rubocop/rake_task"
6
-
7
- RuboCop::RakeTask.new
8
-
9
- RSpec::Core::RakeTask.new(:spec)
10
-
11
- task default: %i[rubocop spec]
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "yabeda/sidekiq"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require "irb"
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
Binary file