airbrake-ruby 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby.rb +21 -2
- data/lib/airbrake-ruby/filter_chain.rb +10 -0
- data/lib/airbrake-ruby/notifier.rb +7 -0
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/filter_chain_spec.rb +39 -0
- data/spec/notifier_spec/options_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef793e3a5a123860495003999ff322f5272a0eb1
|
4
|
+
data.tar.gz: 8d7e363516e3db624ca4944b4857e1e53038faa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f33dab2de0022cd34ee28b3d08746e5136f577af9148fcbbdfb5cf08dbde0f6224e122e8a371b6b145d131fe39d5bcd5fb99bc7a98cdbaef59d5b131c27f2666
|
7
|
+
data.tar.gz: 8119742353a0f1596cff32c453f100d4c3af846bde52183875fc00dadee96ae93d648dce2480d1ae7b6752ca78a92d62e441dbeb4082ced542cc32d2c795943c
|
data/lib/airbrake-ruby.rb
CHANGED
@@ -97,6 +97,9 @@ module Airbrake
|
|
97
97
|
# @macro see_public_api_method
|
98
98
|
def add_filter(_filter = nil, &_block); end
|
99
99
|
|
100
|
+
# @macro see_public_api_method
|
101
|
+
def delete_filter(_filter_class); end
|
102
|
+
|
100
103
|
# @macro see_public_api_method
|
101
104
|
def build_notice(_exception, _params = {}); end
|
102
105
|
|
@@ -115,7 +118,7 @@ module Airbrake
|
|
115
118
|
def merge_context(_context); end
|
116
119
|
|
117
120
|
# @macro see_public_api_method
|
118
|
-
def notify_request(
|
121
|
+
def notify_request(_request_info); end
|
119
122
|
end
|
120
123
|
|
121
124
|
# A Hash that holds all notifiers. The keys of the Hash are notifier
|
@@ -247,11 +250,27 @@ module Airbrake
|
|
247
250
|
# @yieldparam [Airbrake::Notice]
|
248
251
|
# @yieldreturn [void]
|
249
252
|
# @return [void]
|
250
|
-
# @note Once a filter was added, there's no way to delete it
|
251
253
|
def add_filter(filter = nil, &block)
|
252
254
|
@notifiers[:default].add_filter(filter, &block)
|
253
255
|
end
|
254
256
|
|
257
|
+
# Deletes a filter added via {Airbrake#add_filter}.
|
258
|
+
#
|
259
|
+
# @example
|
260
|
+
# # Add a MyFilter filter (we pass an instance here).
|
261
|
+
# Airbrake.add_filter(MyFilter.new)
|
262
|
+
#
|
263
|
+
# # Delete the filter (we pass class name here).
|
264
|
+
# Airbrake.delete_filter(MyFilter)
|
265
|
+
#
|
266
|
+
# @param [Class] filter_class The class of the filter you want to delete
|
267
|
+
# @return [void]
|
268
|
+
# @since v3.1.0
|
269
|
+
# @note This method cannot delete filters assigned via the Proc form.
|
270
|
+
def delete_filter(filter_class)
|
271
|
+
@notifiers[:default].delete_filter(filter_class)
|
272
|
+
end
|
273
|
+
|
255
274
|
# Builds an Airbrake notice. This is useful, if you want to add or modify a
|
256
275
|
# value only for a specific notice. When you're done modifying the notice,
|
257
276
|
# send it with {.notify} or {.notify_sync}.
|
@@ -36,6 +36,16 @@ module Airbrake
|
|
36
36
|
end.reverse!
|
37
37
|
end
|
38
38
|
|
39
|
+
# Deletes a filter from the the filter chain.
|
40
|
+
#
|
41
|
+
# @param [Class] filter_class The class of the filter you want to delete
|
42
|
+
# @return [void]
|
43
|
+
# @since v3.1.0
|
44
|
+
def delete_filter(filter_class)
|
45
|
+
index = @filters.index { |f| f.class.name == filter_class.name }
|
46
|
+
@filters.delete_at(index) if index
|
47
|
+
end
|
48
|
+
|
39
49
|
# Applies all the filters in the filter chain to the given notice. Does not
|
40
50
|
# filter ignored notices.
|
41
51
|
#
|
@@ -5,6 +5,7 @@ module Airbrake
|
|
5
5
|
# @see Airbrake::Config The list of options
|
6
6
|
# @since v1.0.0
|
7
7
|
# @api private
|
8
|
+
# rubocop:disable Metrics/ClassLength
|
8
9
|
class Notifier
|
9
10
|
# @return [String] the label to be prepended to the log output
|
10
11
|
LOG_LABEL = '**Airbrake:'.freeze
|
@@ -57,6 +58,11 @@ module Airbrake
|
|
57
58
|
@filter_chain.add_filter(block_given? ? block : filter)
|
58
59
|
end
|
59
60
|
|
61
|
+
# @macro see_public_api_method
|
62
|
+
def delete_filter(filter_class)
|
63
|
+
@filter_chain.delete_filter(filter_class)
|
64
|
+
end
|
65
|
+
|
60
66
|
# @macro see_public_api_method
|
61
67
|
def build_notice(exception, params = {})
|
62
68
|
if @async_sender.closed?
|
@@ -188,4 +194,5 @@ module Airbrake
|
|
188
194
|
clean_bt
|
189
195
|
end
|
190
196
|
end
|
197
|
+
# rubocop:enable Metrics/ClassLength
|
191
198
|
end
|
data/spec/filter_chain_spec.rb
CHANGED
@@ -47,4 +47,43 @@ RSpec.describe Airbrake::FilterChain do
|
|
47
47
|
subject.refine(notice)
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
describe "#delete_filter" do
|
52
|
+
let(:filter) do
|
53
|
+
Class.new do
|
54
|
+
class << self
|
55
|
+
def name
|
56
|
+
'FooFilter'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def initialize(foo)
|
61
|
+
@foo = foo
|
62
|
+
end
|
63
|
+
|
64
|
+
def call(notice)
|
65
|
+
notice[:params][:foo] << @foo
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it "deletes a class filter" do
|
71
|
+
notice[:params][:foo] = []
|
72
|
+
|
73
|
+
f1 = filter.new(1)
|
74
|
+
subject.add_filter(f1)
|
75
|
+
|
76
|
+
foo_filter_mock = double
|
77
|
+
expect(foo_filter_mock).to(
|
78
|
+
receive(:name).at_least(:once).and_return('FooFilter')
|
79
|
+
)
|
80
|
+
subject.delete_filter(foo_filter_mock)
|
81
|
+
|
82
|
+
f2 = filter.new(2)
|
83
|
+
subject.add_filter(f2)
|
84
|
+
|
85
|
+
subject.refine(notice)
|
86
|
+
expect(notice[:params][:foo]).to eq([2])
|
87
|
+
end
|
88
|
+
end
|
50
89
|
end
|
@@ -141,6 +141,12 @@ RSpec.describe Airbrake::Notifier do
|
|
141
141
|
after { proxy.stop }
|
142
142
|
|
143
143
|
it "is being used if configured" do
|
144
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
|
145
|
+
skip(
|
146
|
+
"We use Webmock 2, which doesn't support Ruby 2.6+. It's " \
|
147
|
+
"safe to run this test on 2.6+ once we upgrade to Webmock 3.5+"
|
148
|
+
)
|
149
|
+
end
|
144
150
|
@airbrake.notify_sync(ex)
|
145
151
|
|
146
152
|
proxied_request = requests.pop(true)
|
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: 3.
|
4
|
+
version: 3.1.0
|
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: 2019-01-
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tdigest
|