airbrake-ruby 4.13.4 → 4.14.1

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: da4c29476df09886ee5e0d9b1b4738cb77a93d9f415c284c57266a64334cf8be
4
- data.tar.gz: c12fad300807903f28b3d3dcdc472e729d6e27e74fca597467774c9ea8ab347a
3
+ metadata.gz: 8a99b9f69c92aab19bd33806452b720f4e193578d5ffa22f79faa780c38d9fa0
4
+ data.tar.gz: 6e19717eef99f7446b8f2e50e79e2eea6787d2b283c0a291821f09ab5e227a8f
5
5
  SHA512:
6
- metadata.gz: '059b5f84a0ef2c158ead7d0026ff9529c03bdcb8e67d5fb95c8a36465af0bd7510ef8426d7ab644e7d3be9d7884f569d130397ca65854ddd03d34f2c332b30f2'
7
- data.tar.gz: 683a8c9d90db59353e70c2f4474825ce583cb8a8d68ff01d895794bd4d6def0daa3ae7898f2ef10398ca24a8361c5fa3d53ae21b270182653431469955b9c578
6
+ metadata.gz: 8ece3a704ef7a11e8994e657e53526c684da53316cc609ff8efc05e5b14cf6eca8b2536233a8ab0bfd8c6bc0997f7c97a9ef073967a8fd85b69f960db9db5757
7
+ data.tar.gz: 28b983d5c3b2b3e7d2a31c5429ffb72b06103569444411c5e7231c76ce308ef143140f40d215401b178aa2022f912914ef7c3f7b14ec4f01c75398342dda97c0
@@ -570,6 +570,7 @@ module Airbrake
570
570
 
571
571
  private
572
572
 
573
+ # rubocop:disable Metrics/AbcSize
573
574
  def process_config_options(config)
574
575
  if config.blacklist_keys.any?
575
576
  blacklist = Airbrake::Filters::KeysBlacklist.new(config.blacklist_keys)
@@ -581,7 +582,6 @@ module Airbrake
581
582
  notice_notifier.add_filter(whitelist)
582
583
  end
583
584
 
584
- return if configured?
585
585
  return unless config.root_directory
586
586
 
587
587
  [
@@ -590,9 +590,12 @@ module Airbrake
590
590
  Airbrake::Filters::GitRepositoryFilter,
591
591
  Airbrake::Filters::GitLastCheckoutFilter,
592
592
  ].each do |filter|
593
+ next if notice_notifier.has_filter?(filter)
594
+
593
595
  notice_notifier.add_filter(filter.new(config.root_directory))
594
596
  end
595
597
  end
598
+ # rubocop:enable Metrics/AbcSize
596
599
  end
597
600
  end
598
601
  # rubocop:enable Metrics/ModuleLength
@@ -76,7 +76,7 @@ module Airbrake
76
76
 
77
77
  # @return [String] customized inspect to lessen the amount of clutter
78
78
  def inspect
79
- @filters.map(&:class).to_s
79
+ filter_classes.to_s
80
80
  end
81
81
 
82
82
  # @return [String] {#inspect} for PrettyPrint
@@ -91,5 +91,19 @@ module Airbrake
91
91
  end
92
92
  q.text(']')
93
93
  end
94
+
95
+ # @param [Class] filter_class
96
+ # @return [Boolean] true if the current chain has an instance of the given
97
+ # class, false otherwise
98
+ # @since v4.14.0
99
+ def includes?(filter_class)
100
+ filter_classes.include?(filter_class)
101
+ end
102
+
103
+ private
104
+
105
+ def filter_classes
106
+ @filters.map(&:class)
107
+ end
94
108
  end
95
109
  end
@@ -82,6 +82,12 @@ module Airbrake
82
82
  @context.merge!(context)
83
83
  end
84
84
 
85
+ # @return [Boolean]
86
+ # @since v4.14.0
87
+ def has_filter?(filter_class) # rubocop:disable Naming/PredicateName
88
+ @filter_chain.includes?(filter_class)
89
+ end
90
+
85
91
  private
86
92
 
87
93
  def convert_to_exception(ex)
@@ -83,6 +83,7 @@ module Airbrake
83
83
 
84
84
  if @pid != Process.pid && @workers.list.empty?
85
85
  @pid = Process.pid
86
+ @workers = ThreadGroup.new
86
87
  spawn_workers
87
88
  end
88
89
 
@@ -2,5 +2,5 @@
2
2
  # More information: http://semver.org/
3
3
  module Airbrake
4
4
  # @return [String] the library version
5
- AIRBRAKE_RUBY_VERSION = '4.13.4'.freeze
5
+ AIRBRAKE_RUBY_VERSION = '4.14.1'.freeze
6
6
  end
@@ -85,6 +85,18 @@ RSpec.describe Airbrake do
85
85
  expect(described_class.notice_notifier).not_to receive(:add_filter)
86
86
  10.times { described_class.configure {} }
87
87
  end
88
+
89
+ it "appends some default filters" do
90
+ allow(described_class.notice_notifier).to receive(:add_filter)
91
+ expect(described_class.notice_notifier).to receive(:add_filter).with(
92
+ an_instance_of(Airbrake::Filters::RootDirectoryFilter),
93
+ )
94
+
95
+ described_class.configure do |c|
96
+ c.project_id = 1
97
+ c.project_key = '2'
98
+ end
99
+ end
88
100
  end
89
101
 
90
102
  context "when blacklist_keys gets configured" do
@@ -89,4 +89,31 @@ RSpec.describe Airbrake::FilterChain do
89
89
  expect(subject.inspect).to eq('[Proc]')
90
90
  end
91
91
  end
92
+
93
+ describe "#includes?" do
94
+ context "when a custom filter class is included in the filter chain" do
95
+ it "returns true" do
96
+ klass = Class.new {}
97
+
98
+ subject.add_filter(klass.new)
99
+ expect(subject.includes?(klass)).to eq(true)
100
+ end
101
+ end
102
+
103
+ context "when Proc filter class is included in the filter chain" do
104
+ it "returns true" do
105
+ subject.add_filter(proc {})
106
+ expect(subject.includes?(Proc)).to eq(true)
107
+ end
108
+ end
109
+
110
+ context "when filter class is NOT included in the filter chain" do
111
+ it "returns false" do
112
+ klass = Class.new {}
113
+
114
+ subject.add_filter(proc {})
115
+ expect(subject.includes?(klass)).to eq(false)
116
+ end
117
+ end
118
+ end
92
119
  end
@@ -389,7 +389,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
389
389
  subject.close
390
390
 
391
391
  expect(promise).to be_an(Airbrake::Promise)
392
- expect(promise.value).to eq('' => nil)
392
+ expect(promise.value).to eq('' => '')
393
393
  end
394
394
 
395
395
  it "checks performance stat configuration" do
@@ -601,7 +601,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
601
601
  body: %r|\A{"queries":\[{"method":"POST","route":"/foo"|,
602
602
  ),
603
603
  ).to have_been_made
604
- expect(retval).to eq('' => nil)
604
+ expect(retval).to eq('' => '')
605
605
  end
606
606
  end
607
607
 
@@ -85,11 +85,31 @@ RSpec.describe Airbrake::ThreadPool do
85
85
  expect(subject).not_to have_workers
86
86
  end
87
87
 
88
- it "respawns workers on fork()", skip: %w[jruby].include?(RUBY_ENGINE) do
89
- pid = fork { expect(subject).to have_workers }
90
- Process.wait(pid)
91
- subject.close
92
- expect(subject).not_to have_workers
88
+ describe "forking behavior" do
89
+ before do
90
+ skip('fork() is unsupported on JRuby') if %w[jruby].include?(RUBY_ENGINE)
91
+ unless Process.respond_to?(:last_status)
92
+ skip('Process.last_status is unsupported on this Ruby')
93
+ end
94
+ end
95
+
96
+ it "respawns workers on fork()" do
97
+ pid = fork { expect(subject).to have_workers }
98
+ Process.wait(pid)
99
+ subject.close
100
+
101
+ expect(Process.last_status).to be_success
102
+ expect(subject).not_to have_workers
103
+ end
104
+
105
+ it "ensures that a new thread group is created per process" do
106
+ subject << 1
107
+ pid = fork { subject.has_workers? }
108
+ Process.wait(pid)
109
+ subject.close
110
+
111
+ expect(Process.last_status).to be_success
112
+ end
93
113
  end
94
114
  end
95
115
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.13.4
4
+ version: 4.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2020-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree3