sidekiq-logstash 2.0.3 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d03d5f447dd18e3fc0989f94b3b79f74cd73a7ec671bafa8655660e90b8ad11b
4
- data.tar.gz: c413e9d405d115d5731190e96dc35eaa853f32a19bf28f32c6556c301333d5d6
3
+ metadata.gz: '09e505554a5ed16d442f68da725e3647a2cd77d12f36897a657d54ff8a3cb8b8'
4
+ data.tar.gz: 917723b1952886cfd29070668209e254198d2d9f3d2807aabbd10af0a5b46608
5
5
  SHA512:
6
- metadata.gz: 2e793efdad13027f544ca878392232c26db9f599f32f1d2aaf7c59ba60e94db318923bd6b754d35b0ff098ab748bba9a0a33a8e28c02895d849a76804bed047c
7
- data.tar.gz: 93a5f3dc665067f09615d3958dfd69c192ca743d07fe444aec389859f72eae6229f60f60ced92799962bfdbabba917d8c2c63d5c8f8bec5dcbc9ce583d40b172
6
+ metadata.gz: f168b77deb49ef0eab0ff308ddfc8539d2b9cf6e1756373ed82301b5a7d5ac063ebefb16fd8a9941b4f0995066b5afcae54b8c9abf6caa1eea190841ca192c15
7
+ data.tar.gz: ad292af73bb01ef763a1e171d1e960c345775db0128f2d904f32ee7166a654a33c065f2d0838c766e2f4057d5a84c054051c21e1945e1728ebb92bfbbb7018ce
@@ -10,16 +10,20 @@ env:
10
10
  GIT_COMMIT_SHA: ${{ github.sha }}
11
11
  GIT_BRANCH: ${{ github.ref }}
12
12
 
13
+ permissions:
14
+ contents: read # to fetch code (actions/checkout)
15
+
13
16
  jobs:
14
17
  linting:
15
18
  runs-on: ubuntu-latest
16
19
 
17
20
  steps:
18
- - uses: actions/checkout@v2
21
+ - uses: actions/checkout@v4
19
22
  - uses: ruby/setup-ruby@v1
20
23
  with:
21
- ruby-version: 2.7
22
- bundler-cache: true
24
+ ruby-version: 3
25
+ bundler-cache: true
26
+
23
27
  - name: Run rubocop
24
28
  run: bundle exec rubocop --format progress
25
29
  build:
@@ -27,13 +31,14 @@ jobs:
27
31
  runs-on: ubuntu-latest
28
32
  strategy:
29
33
  matrix:
30
- ruby: ['2.6', '2.7', '3.0', '3.1']
34
+ ruby: ['3.0', '3.1', '3.2', '3.3']
31
35
 
32
36
  steps:
33
- - uses: actions/checkout@v2
37
+ - uses: actions/checkout@v4
34
38
  - uses: ruby/setup-ruby@v1
35
39
  with:
36
40
  ruby-version: ${{ matrix.ruby }}
37
41
  bundler-cache: true
42
+
38
43
  - name: Run tests
39
44
  run: bundle exec rake
@@ -10,12 +10,10 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
 
12
12
  steps:
13
- - uses: actions/checkout@master
14
-
15
- - name: Set up Ruby 2.7
16
- uses: actions/setup-ruby@v1
13
+ - uses: actions/checkout@v4
14
+ - uses: actions/setup-ruby@v1
17
15
  with:
18
- ruby-version: 2.7.x
16
+ ruby-version: 3
19
17
 
20
18
  - name: Publish to RubyGems
21
19
  run: |
data/.rubocop.yml CHANGED
@@ -7,7 +7,7 @@ AllCops:
7
7
  DisplayCopNames: true
8
8
  DisplayStyleGuide: true
9
9
  NewCops: enable
10
- TargetRubyVersion: 2.5
10
+ TargetRubyVersion: 3.0
11
11
 
12
12
  Metrics/BlockLength:
13
13
  Exclude:
data/Gemfile CHANGED
@@ -4,5 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'rubocop-rake'
8
- gem 'rubocop-rspec'
7
+ gem 'factory_bot', github: 'thoughtbot/factory_bot', branch: 'main'
8
+ gem 'rake'
9
+ gem 'rspec'
10
+ gem 'rspec-json_expectations'
11
+ gem 'rubocop-performance'
data/README.md CHANGED
@@ -33,6 +33,7 @@ Sidekiq::Logstash turns your [Sidekiq](https://github.com/mperham/sidekiq) log i
33
33
  Add one of the following lines to your application's Gemfile:
34
34
 
35
35
  ```ruby
36
+ gem 'sidekiq-logstash', '~> 3.0' # Sidekiq 7
36
37
  gem 'sidekiq-logstash', '~> 2.0' # Sidekiq 6
37
38
  gem 'sidekiq-logstash', '< 2' # Sidekiq 5 or older
38
39
  ```
@@ -78,6 +79,10 @@ Sidekiq::Logstash.configure do |config|
78
79
  config.custom_options = lambda do |payload|
79
80
  payload['my_custom_field'] = 'my_custom_value'
80
81
  end
82
+
83
+ # by default, sidekiq-logstash removes the default error handler
84
+ # to keep it, simply set this to true
85
+ config.keep_default_error_handler = true
81
86
  end
82
87
  ```
83
88
 
@@ -27,7 +27,7 @@ module Sidekiq
27
27
 
28
28
  class CompiledFilter # :nodoc:
29
29
  def self.compile(filters)
30
- return ->(args) { args.dup } if filters.empty?
30
+ return lambda(&:dup) if filters.empty?
31
31
 
32
32
  strings = []
33
33
  regexps = []
@@ -130,7 +130,7 @@ module Sidekiq
130
130
  def deep_stringify!(args)
131
131
  case args
132
132
  when Hash
133
- args.map { |key, value| [deep_stringify!(key), deep_stringify!(value)] }.to_h
133
+ args.to_h { |key, value| [deep_stringify!(key), deep_stringify!(value)] }
134
134
  when Array
135
135
  args.map! { |val| deep_stringify!(val) }
136
136
  else
@@ -4,7 +4,7 @@ module Sidekiq
4
4
  module Logstash
5
5
  # Class that allows to configure the gem behaviour.
6
6
  class Configuration
7
- attr_accessor :custom_options, :filter_args, :job_start_log
7
+ attr_accessor :custom_options, :filter_args, :job_start_log, :keep_default_error_handler
8
8
 
9
9
  def initialize
10
10
  @filter_args = []
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Logstash
5
- VERSION = '2.0.3'
5
+ VERSION = '3.1.0'
6
6
  end
7
7
  end
@@ -4,7 +4,6 @@ require 'sidekiq/logstash/configuration'
4
4
  require 'sidekiq/logstash/version'
5
5
  require 'sidekiq/logging/logstash_formatter'
6
6
  require 'sidekiq/logging/argument_filter'
7
- require 'sidekiq/logstash_job_logger'
8
7
 
9
8
  module Sidekiq
10
9
  # Main level module for Sidekiq::Logstash.
@@ -22,21 +21,20 @@ module Sidekiq
22
21
  def self.setup(_opts = {})
23
22
  # Calls Sidekiq.configure_server to inject logics
24
23
  Sidekiq.configure_server do |config|
25
- if defined?(Sidekiq::ExceptionHandler::Logger)
26
- # Remove default Sidekiq error_handler that logs errors
27
- # NOTE: this only exists up until Sidekiq 6.4.x
28
- config.error_handlers.delete_if { |h| h.is_a?(Sidekiq::ExceptionHandler::Logger) }
29
- end
24
+ require 'sidekiq/logstash_job_logger'
30
25
 
31
- # Add logstash support
32
- if config.respond_to?(:[]=)
33
- # Only available from Sidekiq 6.5
34
- config[:job_logger] = Sidekiq::LogstashJobLogger
35
- else
36
- # This is deprecated and will be removed in Sidekiq 7.0
37
- config.options[:job_logger] = Sidekiq::LogstashJobLogger
26
+ # Remove default, noisy error handler,
27
+ # unless LogStash.configuration.keep_default_error_handler is set to true
28
+ unless configuration.keep_default_error_handler
29
+ config.error_handlers.delete(Sidekiq::Config::ERROR_HANDLER)
30
+ # Insert a no-op error handler to prevent Sidekiq from logging to STDOUT
31
+ # because of empty error_handlers (see link).
32
+ # https://github.com/mperham/sidekiq/blob/02153c17360e712d9a94c08406fe7c057c4d7635/lib/sidekiq/config.rb#L258
33
+ config.error_handlers << proc {}
38
34
  end
39
35
 
36
+ # Add logstash support
37
+ config[:job_logger] = Sidekiq::LogstashJobLogger
40
38
  # Set custom formatter for Sidekiq logger
41
39
  config.logger.formatter = Sidekiq::Logging::LogstashFormatter.new
42
40
  end
@@ -19,15 +19,10 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
21
  spec.require_paths = ['lib']
22
- spec.required_ruby_version = '>= 2.5.0'
22
+ spec.required_ruby_version = '>= 3.0.0'
23
23
 
24
24
  spec.add_dependency 'logstash-event', '~> 1.2'
25
- spec.add_runtime_dependency 'sidekiq', '>= 6.0', '<7'
25
+ spec.add_dependency 'sidekiq', '~> 7.0'
26
26
 
27
- spec.add_development_dependency 'factory_bot', '~> 6.1'
28
- spec.add_development_dependency 'rake', '>= 10'
29
- spec.add_development_dependency 'rspec', '~> 3.0'
30
- spec.add_development_dependency 'rspec-json_expectations', '~> 2.1.0'
31
- spec.add_development_dependency 'rubocop-performance', '~> 1.5'
32
27
  spec.metadata['rubygems_mfa_required'] = 'true'
33
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-logstash
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Giuffrida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-12 00:00:00.000000000 Z
11
+ date: 2024-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-event
@@ -26,94 +26,18 @@ dependencies:
26
26
  version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sidekiq
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '6.0'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '7'
37
- type: :runtime
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '6.0'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '7'
47
- - !ruby/object:Gem::Dependency
48
- name: factory_bot
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '6.1'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '6.1'
61
- - !ruby/object:Gem::Dependency
62
- name: rake
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '10'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '10'
75
- - !ruby/object:Gem::Dependency
76
- name: rspec
77
29
  requirement: !ruby/object:Gem::Requirement
78
30
  requirements:
79
31
  - - "~>"
80
32
  - !ruby/object:Gem::Version
81
- version: '3.0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '3.0'
89
- - !ruby/object:Gem::Dependency
90
- name: rspec-json_expectations
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: 2.1.0
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: 2.1.0
103
- - !ruby/object:Gem::Dependency
104
- name: rubocop-performance
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '1.5'
110
- type: :development
33
+ version: '7.0'
34
+ type: :runtime
111
35
  prerelease: false
112
36
  version_requirements: !ruby/object:Gem::Requirement
113
37
  requirements:
114
38
  - - "~>"
115
39
  - !ruby/object:Gem::Version
116
- version: '1.5'
40
+ version: '7.0'
117
41
  description: 'Sidekiq::Logstash turns your Sidekiq log into an organised, aggregated,
118
42
  JSON-syntax log ready to be sent to a logstash server.
119
43
 
@@ -157,14 +81,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
81
  requirements:
158
82
  - - ">="
159
83
  - !ruby/object:Gem::Version
160
- version: 2.5.0
84
+ version: 3.0.0
161
85
  required_rubygems_version: !ruby/object:Gem::Requirement
162
86
  requirements:
163
87
  - - ">="
164
88
  - !ruby/object:Gem::Version
165
89
  version: '0'
166
90
  requirements: []
167
- rubygems_version: 3.1.6
91
+ rubygems_version: 3.4.19
168
92
  signing_key:
169
93
  specification_version: 4
170
94
  summary: Logstash plugin for Sidekiq