airbrake-ruby 5.0.0.rc.2-java → 5.2.0-java
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 +1 -0
- data/lib/airbrake-ruby/backtrace.rb +6 -5
- data/lib/airbrake-ruby/config.rb +19 -38
- data/lib/airbrake-ruby/config/processor.rb +8 -17
- data/lib/airbrake-ruby/config/validator.rb +2 -0
- data/lib/airbrake-ruby/file_cache.rb +1 -1
- data/lib/airbrake-ruby/filter_chain.rb +1 -0
- data/lib/airbrake-ruby/filters/dependency_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +1 -2
- data/lib/airbrake-ruby/filters/git_repository_filter.rb +3 -0
- data/lib/airbrake-ruby/filters/git_revision_filter.rb +2 -0
- data/lib/airbrake-ruby/filters/keys_filter.rb +21 -13
- data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/sql_filter.rb +4 -4
- data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/thread_filter.rb +3 -2
- data/lib/airbrake-ruby/grouppable.rb +1 -1
- data/lib/airbrake-ruby/ignorable.rb +1 -0
- data/lib/airbrake-ruby/mergeable.rb +1 -1
- data/lib/airbrake-ruby/notice_notifier.rb +1 -0
- data/lib/airbrake-ruby/performance_breakdown.rb +1 -6
- data/lib/airbrake-ruby/performance_notifier.rb +1 -14
- data/lib/airbrake-ruby/promise.rb +1 -0
- data/lib/airbrake-ruby/query.rb +1 -6
- data/lib/airbrake-ruby/queue.rb +1 -8
- data/lib/airbrake-ruby/remote_settings.rb +16 -54
- data/lib/airbrake-ruby/remote_settings/callback.rb +44 -0
- data/lib/airbrake-ruby/remote_settings/settings_data.rb +14 -14
- data/lib/airbrake-ruby/request.rb +1 -8
- data/lib/airbrake-ruby/stat.rb +1 -12
- data/lib/airbrake-ruby/sync_sender.rb +1 -0
- data/lib/airbrake-ruby/tdigest.rb +2 -0
- data/lib/airbrake-ruby/thread_pool.rb +1 -0
- data/lib/airbrake-ruby/truncator.rb +8 -2
- data/lib/airbrake-ruby/version.rb +2 -2
- data/spec/backtrace_spec.rb +26 -26
- data/spec/code_hunk_spec.rb +2 -2
- data/spec/config/processor_spec.rb +21 -101
- data/spec/config_spec.rb +5 -29
- data/spec/filters/gem_root_filter_spec.rb +4 -4
- data/spec/filters/git_last_checkout_filter_spec.rb +1 -1
- data/spec/filters/keys_allowlist_spec.rb +1 -0
- data/spec/filters/keys_blocklist_spec.rb +10 -0
- data/spec/filters/root_directory_filter_spec.rb +4 -4
- data/spec/filters/sql_filter_spec.rb +2 -2
- data/spec/filters/thread_filter_spec.rb +1 -1
- data/spec/notice_notifier/options_spec.rb +2 -2
- data/spec/notice_notifier_spec.rb +2 -2
- data/spec/notice_spec.rb +1 -1
- data/spec/performance_breakdown_spec.rb +0 -12
- data/spec/performance_notifier_spec.rb +0 -25
- data/spec/query_spec.rb +1 -11
- data/spec/queue_spec.rb +1 -13
- data/spec/remote_settings/callback_spec.rb +143 -0
- data/spec/remote_settings/settings_data_spec.rb +34 -13
- data/spec/remote_settings_spec.rb +40 -83
- data/spec/request_spec.rb +1 -13
- data/spec/spec_helper.rb +4 -4
- data/spec/stat_spec.rb +0 -9
- data/spec/tdigest_spec.rb +1 -1
- metadata +8 -5
@@ -4,7 +4,6 @@ module Airbrake
|
|
4
4
|
# @see Airbrake.notify_request
|
5
5
|
# @api public
|
6
6
|
# @since v3.2.0
|
7
|
-
# rubocop:disable Metrics/ParameterLists
|
8
7
|
class Request
|
9
8
|
include HashKeyable
|
10
9
|
include Ignorable
|
@@ -12,15 +11,12 @@ module Airbrake
|
|
12
11
|
include Mergeable
|
13
12
|
include Grouppable
|
14
13
|
|
15
|
-
attr_accessor :method, :route, :status_code, :
|
16
|
-
:timing, :time
|
14
|
+
attr_accessor :method, :route, :status_code, :timing, :time
|
17
15
|
|
18
16
|
def initialize(
|
19
17
|
method:,
|
20
18
|
route:,
|
21
19
|
status_code:,
|
22
|
-
start_time: Time.now,
|
23
|
-
end_time: start_time + 1,
|
24
20
|
timing: nil,
|
25
21
|
time: Time.now
|
26
22
|
)
|
@@ -28,8 +24,6 @@ module Airbrake
|
|
28
24
|
@method = method
|
29
25
|
@route = route
|
30
26
|
@status_code = status_code
|
31
|
-
@start_time = start_time
|
32
|
-
@end_time = end_time
|
33
27
|
@timing = timing
|
34
28
|
@time = time
|
35
29
|
end
|
@@ -51,5 +45,4 @@ module Airbrake
|
|
51
45
|
}.delete_if { |_key, val| val.nil? }
|
52
46
|
end
|
53
47
|
end
|
54
|
-
# rubocop:enable Metrics/ParameterLists
|
55
48
|
end
|
data/lib/airbrake-ruby/stat.rb
CHANGED
@@ -9,7 +9,7 @@ module Airbrake
|
|
9
9
|
#
|
10
10
|
# @example
|
11
11
|
# stat = Airbrake::Stat.new
|
12
|
-
# stat.
|
12
|
+
# stat.increment_ms(2000)
|
13
13
|
# stat.to_h # Pack and serialize data so it can be transmitted.
|
14
14
|
#
|
15
15
|
# @since v3.2.0
|
@@ -41,17 +41,6 @@ module Airbrake
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
# Increments tdigest timings and updates tdigest with the difference between
|
45
|
-
# +end_time+ and +start_time+.
|
46
|
-
#
|
47
|
-
# @param [Date] start_time
|
48
|
-
# @param [Date] end_time
|
49
|
-
# @return [void]
|
50
|
-
def increment(start_time, end_time = nil)
|
51
|
-
end_time ||= Time.new
|
52
|
-
increment_ms((end_time - start_time) * 1000)
|
53
|
-
end
|
54
|
-
|
55
44
|
# Increments tdigest timings and updates tdigest with given +ms+ value.
|
56
45
|
#
|
57
46
|
# @param [Float] ms
|
@@ -200,6 +200,7 @@ module Airbrake
|
|
200
200
|
unless (0..1).cover?(item)
|
201
201
|
raise ArgumentError, "p should be in [0,1], got #{item}"
|
202
202
|
end
|
203
|
+
|
203
204
|
if size == 0
|
204
205
|
nil
|
205
206
|
else
|
@@ -271,6 +272,7 @@ module Airbrake
|
|
271
272
|
shift = 7
|
272
273
|
while (v & 0x80) != 0
|
273
274
|
raise 'Shift too large in decode' if shift > 28
|
275
|
+
|
274
276
|
v = counts_bytes.shift || 0
|
275
277
|
z += (v & 0x7f) << shift
|
276
278
|
shift += 7
|
@@ -12,6 +12,10 @@ module Airbrake
|
|
12
12
|
# strings with +ENCODING_OPTIONS+
|
13
13
|
TEMP_ENCODING = 'utf-16'.freeze
|
14
14
|
|
15
|
+
# @return [Array<Encoding>] encodings that are eligible for fixing invalid
|
16
|
+
# characters
|
17
|
+
SUPPORTED_ENCODINGS = [Encoding::UTF_8, Encoding::ASCII].freeze
|
18
|
+
|
15
19
|
# @return [String] what to append when something is a circular reference
|
16
20
|
CIRCULAR = '[Circular]'.freeze
|
17
21
|
|
@@ -35,6 +39,7 @@ module Airbrake
|
|
35
39
|
def truncate(object, seen = Set.new)
|
36
40
|
if seen.include?(object.object_id)
|
37
41
|
return CIRCULAR if CIRCULAR_TYPES.any? { |t| object.is_a?(t) }
|
42
|
+
|
38
43
|
return object
|
39
44
|
end
|
40
45
|
truncate_object(object, seen << object.object_id)
|
@@ -63,6 +68,7 @@ module Airbrake
|
|
63
68
|
def truncate_string(str)
|
64
69
|
fixed_str = replace_invalid_characters(str)
|
65
70
|
return fixed_str if fixed_str.length <= @max_size
|
71
|
+
|
66
72
|
(fixed_str.slice(0, @max_size) + TRUNCATED).freeze
|
67
73
|
end
|
68
74
|
|
@@ -76,6 +82,7 @@ module Airbrake
|
|
76
82
|
truncated_hash = {}
|
77
83
|
hash.each_with_index do |(key, val), idx|
|
78
84
|
break if idx + 1 > @max_size
|
85
|
+
|
79
86
|
truncated_hash[key] = truncate(val, seen)
|
80
87
|
end
|
81
88
|
|
@@ -103,8 +110,7 @@ module Airbrake
|
|
103
110
|
# @return [String] a UTF-8 encoded string
|
104
111
|
# @see https://github.com/flori/json/commit/3e158410e81f94dbbc3da6b7b35f4f64983aa4e3
|
105
112
|
def replace_invalid_characters(str)
|
106
|
-
|
107
|
-
utf8_string = (encoding == Encoding::UTF_8 || encoding == Encoding::ASCII)
|
113
|
+
utf8_string = SUPPORTED_ENCODINGS.include?(str.encoding)
|
108
114
|
return str if utf8_string && str.valid_encoding?
|
109
115
|
|
110
116
|
temp_str = str.dup
|
@@ -3,10 +3,10 @@
|
|
3
3
|
module Airbrake
|
4
4
|
# @return [String] the library version
|
5
5
|
# @api public
|
6
|
-
AIRBRAKE_RUBY_VERSION = '5.
|
6
|
+
AIRBRAKE_RUBY_VERSION = '5.2.0'.freeze
|
7
7
|
|
8
8
|
# @return [Hash{Symbol=>String}] the information about the notifier library
|
9
|
-
# @since
|
9
|
+
# @since v5.0.0
|
10
10
|
# @api public
|
11
11
|
NOTIFIER_INFO = {
|
12
12
|
name: 'airbrake-ruby'.freeze,
|
data/spec/backtrace_spec.rb
CHANGED
@@ -2,7 +2,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
2
2
|
describe ".parse" do
|
3
3
|
context "UNIX backtrace" do
|
4
4
|
let(:parsed_backtrace) do
|
5
|
-
# rubocop:disable
|
5
|
+
# rubocop:disable Layout/LineLength, Style/HashSyntax, Layout/SpaceAroundOperators, Layout/SpaceInsideHashLiteralBraces
|
6
6
|
[{:file=>"/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb", :line=>23, :function=>"<top (required)>"},
|
7
7
|
{:file=>"/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb", :line=>54, :function=>"require"},
|
8
8
|
{:file=>"/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb", :line=>54, :function=>"require"},
|
@@ -16,7 +16,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
16
16
|
{:file=>"/home/kyrylo/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb", :line=>73, :function=>"run"},
|
17
17
|
{:file=>"/home/kyrylo/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb", :line=>41, :function=>"invoke"},
|
18
18
|
{:file=>"/home/kyrylo/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/exe/rspec", :line=>4, :function=>"<main>"}]
|
19
|
-
# rubocop:enable
|
19
|
+
# rubocop:enable Layout/LineLength, Style/HashSyntax, Layout/SpaceAroundOperators, Layout/SpaceInsideHashLiteralBraces
|
20
20
|
end
|
21
21
|
|
22
22
|
it "returns a properly formatted array of hashes" do
|
@@ -34,10 +34,10 @@ RSpec.describe Airbrake::Backtrace do
|
|
34
34
|
let(:ex) { AirbrakeTestError.new.tap { |e| e.set_backtrace(windows_bt) } }
|
35
35
|
|
36
36
|
let(:parsed_backtrace) do
|
37
|
-
# rubocop:disable
|
37
|
+
# rubocop:disable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
|
38
38
|
[{:file=>"C:/Program Files/Server/app/models/user.rb", :line=>13, :function=>"magic"},
|
39
39
|
{:file=>"C:/Program Files/Server/app/controllers/users_controller.rb", :line=>8, :function=>"index"}]
|
40
|
-
# rubocop:enable
|
40
|
+
# rubocop:enable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
|
41
41
|
end
|
42
42
|
|
43
43
|
it "returns a properly formatted array of hashes" do
|
@@ -47,7 +47,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
47
47
|
|
48
48
|
context "JRuby Java exceptions" do
|
49
49
|
let(:backtrace_array) do
|
50
|
-
# rubocop:disable
|
50
|
+
# rubocop:disable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
|
51
51
|
[{:file=>"InstanceMethodInvoker.java", :line=>26, :function=>"org.jruby.java.invokers.InstanceMethodInvoker.call"},
|
52
52
|
{:file=>"Interpreter.java", :line=>126, :function=>"org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL"},
|
53
53
|
{:file=>"RubyKernel$INVOKER$s$0$3$eval19.gen", :line=>nil, :function=>"org.jruby.RubyKernel$INVOKER$s$0$3$eval19.call"},
|
@@ -59,7 +59,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
59
59
|
{:file=>"Compiler.java", :line=>111, :function=>"org.jruby.ir.Compiler$1.load"},
|
60
60
|
{:file=>"Main.java", :line=>225, :function=>"org.jruby.Main.run"},
|
61
61
|
{:file=>"Main.java", :line=>197, :function=>"org.jruby.Main.main"}]
|
62
|
-
# rubocop:enable
|
62
|
+
# rubocop:enable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
|
63
63
|
end
|
64
64
|
|
65
65
|
it "returns a properly formatted array of hashes" do
|
@@ -72,21 +72,21 @@ RSpec.describe Airbrake::Backtrace do
|
|
72
72
|
|
73
73
|
context "JRuby classloader exceptions" do
|
74
74
|
let(:backtrace) do
|
75
|
-
# rubocop:disable
|
75
|
+
# rubocop:disable Layout/LineLength
|
76
76
|
['uri_3a_classloader_3a_.META_minus_INF.jruby_dot_home.lib.ruby.stdlib.net.protocol.rbuf_fill(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/net/protocol.rb:158)',
|
77
77
|
'bin.processors.image_uploader.block in make_streams(bin/processors/image_uploader.rb:21)',
|
78
78
|
'uri_3a_classloader_3a_.gems.faye_minus_websocket_minus_0_dot_10_dot_5.lib.faye.websocket.api.invokeOther13:dispatch_event(uri_3a_classloader_3a_/gems/faye_minus_websocket_minus_0_dot_10_dot_5/lib/faye/websocket/uri:classloader:/gems/faye-websocket-0.10.5/lib/faye/websocket/api.rb:109)',
|
79
79
|
'tmp.jruby9022301782566983632extract.$dot.META_minus_INF.rails.file(/tmp/jruby9022301782566983632extract/./META-INF/rails.rb:13)']
|
80
|
-
# rubocop:enable
|
80
|
+
# rubocop:enable Layout/LineLength
|
81
81
|
end
|
82
82
|
|
83
83
|
let(:parsed_backtrace) do
|
84
|
-
# rubocop:disable
|
84
|
+
# rubocop:disable Layout/LineLength
|
85
85
|
[{ file: 'uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/net/protocol.rb', line: 158, function: 'uri_3a_classloader_3a_.META_minus_INF.jruby_dot_home.lib.ruby.stdlib.net.protocol.rbuf_fill' },
|
86
86
|
{ file: 'bin/processors/image_uploader.rb', line: 21, function: 'bin.processors.image_uploader.block in make_streams' },
|
87
87
|
{ file: 'uri_3a_classloader_3a_/gems/faye_minus_websocket_minus_0_dot_10_dot_5/lib/faye/websocket/uri:classloader:/gems/faye-websocket-0.10.5/lib/faye/websocket/api.rb', line: 109, function: 'uri_3a_classloader_3a_.gems.faye_minus_websocket_minus_0_dot_10_dot_5.lib.faye.websocket.api.invokeOther13:dispatch_event' },
|
88
88
|
{ file: '/tmp/jruby9022301782566983632extract/./META-INF/rails.rb', line: 13, function: 'tmp.jruby9022301782566983632extract.$dot.META_minus_INF.rails.file' }]
|
89
|
-
# rubocop:enable
|
89
|
+
# rubocop:enable Layout/LineLength
|
90
90
|
end
|
91
91
|
|
92
92
|
let(:ex) { JavaAirbrakeTestError.new.tap { |e| e.set_backtrace(backtrace) } }
|
@@ -99,19 +99,19 @@ RSpec.describe Airbrake::Backtrace do
|
|
99
99
|
|
100
100
|
context "JRuby non-throwable exceptions" do
|
101
101
|
let(:backtrace) do
|
102
|
-
# rubocop:disable
|
102
|
+
# rubocop:disable Layout/LineLength
|
103
103
|
['org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(org/postgresql/core/v3/ConnectionFactoryImpl.java:257)',
|
104
104
|
'org.postgresql.core.ConnectionFactory.openConnection(org/postgresql/core/ConnectionFactory.java:65)',
|
105
105
|
'org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(org/postgresql/jdbc2/AbstractJdbc2Connection.java:149)']
|
106
|
-
# rubocop:enable
|
106
|
+
# rubocop:enable Layout/LineLength
|
107
107
|
end
|
108
108
|
|
109
109
|
let(:parsed_backtrace) do
|
110
|
-
# rubocop:disable
|
110
|
+
# rubocop:disable Layout/LineLength
|
111
111
|
[{ file: 'org/postgresql/core/v3/ConnectionFactoryImpl.java', line: 257, function: 'org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl' },
|
112
112
|
{ file: 'org/postgresql/core/ConnectionFactory.java', line: 65, function: 'org.postgresql.core.ConnectionFactory.openConnection' },
|
113
113
|
{ file: 'org/postgresql/jdbc2/AbstractJdbc2Connection.java', line: 149, function: 'org.postgresql.jdbc2.AbstractJdbc2Connection.<init>' }]
|
114
|
-
# rubocop:enable
|
114
|
+
# rubocop:enable Layout/LineLength
|
115
115
|
end
|
116
116
|
|
117
117
|
let(:ex) { AirbrakeTestError.new.tap { |e| e.set_backtrace(backtrace) } }
|
@@ -123,22 +123,22 @@ RSpec.describe Airbrake::Backtrace do
|
|
123
123
|
|
124
124
|
context "generic backtrace" do
|
125
125
|
context "when function is absent" do
|
126
|
-
# rubocop:disable
|
126
|
+
# rubocop:disable Layout/LineLength
|
127
127
|
let(:generic_bt) do
|
128
128
|
["/home/bingo/bango/assets/stylesheets/error_pages.scss:139:in `animation'",
|
129
129
|
"/home/bingo/bango/assets/stylesheets/error_pages.scss:139",
|
130
130
|
"/home/bingo/.gem/ruby/2.2.2/gems/sass-3.4.20/lib/sass/tree/visitors/perform.rb:349:in `block in visit_mixin'"]
|
131
131
|
end
|
132
|
-
# rubocop:enable
|
132
|
+
# rubocop:enable Layout/LineLength
|
133
133
|
|
134
134
|
let(:ex) { AirbrakeTestError.new.tap { |e| e.set_backtrace(generic_bt) } }
|
135
135
|
|
136
136
|
let(:parsed_backtrace) do
|
137
|
-
# rubocop:disable
|
137
|
+
# rubocop:disable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
|
138
138
|
[{:file=>"/home/bingo/bango/assets/stylesheets/error_pages.scss", :line=>139, :function=>"animation"},
|
139
139
|
{:file=>"/home/bingo/bango/assets/stylesheets/error_pages.scss", :line=>139, :function=>nil},
|
140
140
|
{:file=>"/home/bingo/.gem/ruby/2.2.2/gems/sass-3.4.20/lib/sass/tree/visitors/perform.rb", :line=>349, :function=>"block in visit_mixin"}]
|
141
|
-
# rubocop:enable
|
141
|
+
# rubocop:enable Layout/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
|
142
142
|
end
|
143
143
|
|
144
144
|
it "returns a properly formatted array of hashes" do
|
@@ -277,9 +277,9 @@ RSpec.describe Airbrake::Backtrace do
|
|
277
277
|
93 => ' begin',
|
278
278
|
94 => ' json = @payload.to_json',
|
279
279
|
95 => ' rescue *JSON_EXCEPTIONS => ex',
|
280
|
-
# rubocop:disable
|
280
|
+
# rubocop:disable Layout/LineLength,Lint/InterpolationCheck
|
281
281
|
96 => ' @config.logger.debug("#{LOG_LABEL} `notice.to_json` failed: #{ex.class}: #{ex}")',
|
282
|
-
# rubocop:enable
|
282
|
+
# rubocop:enable Layout/LineLength,Lint/InterpolationCheck
|
283
283
|
},
|
284
284
|
},
|
285
285
|
{
|
@@ -325,9 +325,9 @@ RSpec.describe Airbrake::Backtrace do
|
|
325
325
|
93 => ' begin',
|
326
326
|
94 => ' json = @payload.to_json',
|
327
327
|
95 => ' rescue *JSON_EXCEPTIONS => ex',
|
328
|
-
# rubocop:disable
|
328
|
+
# rubocop:disable Layout/LineLength,Lint/InterpolationCheck
|
329
329
|
96 => ' @config.logger.debug("#{LOG_LABEL} `notice.to_json` failed: #{ex.class}: #{ex}")',
|
330
|
-
# rubocop:enable
|
330
|
+
# rubocop:enable Layout/LineLength,Lint/InterpolationCheck
|
331
331
|
},
|
332
332
|
},
|
333
333
|
]
|
@@ -357,9 +357,9 @@ RSpec.describe Airbrake::Backtrace do
|
|
357
357
|
93 => ' begin',
|
358
358
|
94 => ' json = @payload.to_json',
|
359
359
|
95 => ' rescue *JSON_EXCEPTIONS => ex',
|
360
|
-
# rubocop:disable
|
360
|
+
# rubocop:disable Layout/LineLength,Lint/InterpolationCheck
|
361
361
|
96 => ' @config.logger.debug("#{LOG_LABEL} `notice.to_json` failed: #{ex.class}: #{ex}")',
|
362
|
-
# rubocop:enable
|
362
|
+
# rubocop:enable Layout/LineLength,Lint/InterpolationCheck
|
363
363
|
},
|
364
364
|
},
|
365
365
|
{
|
@@ -370,9 +370,9 @@ RSpec.describe Airbrake::Backtrace do
|
|
370
370
|
93 => ' begin',
|
371
371
|
94 => ' json = @payload.to_json',
|
372
372
|
95 => ' rescue *JSON_EXCEPTIONS => ex',
|
373
|
-
# rubocop:disable
|
373
|
+
# rubocop:disable Layout/LineLength,Lint/InterpolationCheck
|
374
374
|
96 => ' @config.logger.debug("#{LOG_LABEL} `notice.to_json` failed: #{ex.class}: #{ex}")',
|
375
|
-
# rubocop:enable
|
375
|
+
# rubocop:enable Layout/LineLength,Lint/InterpolationCheck
|
376
376
|
97 => ' else',
|
377
377
|
},
|
378
378
|
},
|
data/spec/code_hunk_spec.rb
CHANGED
@@ -34,9 +34,9 @@ RSpec.describe Airbrake::CodeHunk do
|
|
34
34
|
eq(
|
35
35
|
1 => 'module Airbrake',
|
36
36
|
2 => ' ##',
|
37
|
-
# rubocop:disable
|
37
|
+
# rubocop:disable Layout/LineLength
|
38
38
|
3 => ' # Represents a chunk of information that is meant to be either sent to',
|
39
|
-
# rubocop:enable
|
39
|
+
# rubocop:enable Layout/LineLength
|
40
40
|
),
|
41
41
|
)
|
42
42
|
end
|
@@ -53,27 +53,32 @@ RSpec.describe Airbrake::Config::Processor do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
context "when the config sets environment to 'test'" do
|
57
|
+
let(:config) { Airbrake::Config.new(project_id: 123, environment: 'test') }
|
58
|
+
|
59
|
+
it "doesn't set remote settings" do
|
60
|
+
expect(Airbrake::RemoteSettings).not_to receive(:poll)
|
61
|
+
described_class.new(config).process_remote_configuration
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
56
65
|
context "when the config defines a project_id" do
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
66
|
+
let(:config) do
|
67
|
+
Airbrake::Config.new(project_id: 123, environment: 'not-test')
|
68
|
+
end
|
61
69
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
70
|
+
it "sets remote settings" do
|
71
|
+
expect(Airbrake::RemoteSettings).to receive(:poll)
|
72
|
+
described_class.new(config).process_remote_configuration
|
66
73
|
end
|
74
|
+
end
|
67
75
|
|
68
|
-
|
69
|
-
|
70
|
-
Airbrake::Config.new(project_id: 123, __remote_configuration: true)
|
71
|
-
end
|
76
|
+
context "when the config disables the remote_config option" do
|
77
|
+
let(:config) { Airbrake::Config.new(project_id: 123, remote_config: false) }
|
72
78
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
79
|
+
it "doesn't set remote settings" do
|
80
|
+
expect(Airbrake::RemoteSettings).not_to receive(:poll)
|
81
|
+
described_class.new(config).process_remote_configuration
|
77
82
|
end
|
78
83
|
end
|
79
84
|
end
|
@@ -135,89 +140,4 @@ RSpec.describe Airbrake::Config::Processor do
|
|
135
140
|
end
|
136
141
|
end
|
137
142
|
end
|
138
|
-
|
139
|
-
describe "#poll_callback" do
|
140
|
-
let(:logger) { Logger.new(File::NULL) }
|
141
|
-
|
142
|
-
let(:config) do
|
143
|
-
Airbrake::Config.new(
|
144
|
-
project_id: 123,
|
145
|
-
__remote_configuration: true,
|
146
|
-
logger: logger,
|
147
|
-
)
|
148
|
-
end
|
149
|
-
|
150
|
-
let(:data) do
|
151
|
-
instance_double(Airbrake::RemoteSettings::SettingsData)
|
152
|
-
end
|
153
|
-
|
154
|
-
before do
|
155
|
-
allow(data).to receive(:to_h)
|
156
|
-
allow(data).to receive(:error_host)
|
157
|
-
allow(data).to receive(:apm_host)
|
158
|
-
allow(data).to receive(:error_notifications?)
|
159
|
-
allow(data).to receive(:performance_stats?)
|
160
|
-
end
|
161
|
-
|
162
|
-
it "logs given data" do
|
163
|
-
expect(logger).to receive(:debug).with(/applying remote settings/)
|
164
|
-
described_class.new(config).poll_callback(data)
|
165
|
-
end
|
166
|
-
|
167
|
-
it "sets the error_notifications option" do
|
168
|
-
config.error_notifications = false
|
169
|
-
expect(data).to receive(:error_notifications?).and_return(true)
|
170
|
-
|
171
|
-
described_class.new(config).poll_callback(data)
|
172
|
-
expect(config.error_notifications).to eq(true)
|
173
|
-
end
|
174
|
-
|
175
|
-
it "sets the performance_stats option" do
|
176
|
-
config.performance_stats = false
|
177
|
-
expect(data).to receive(:performance_stats?).and_return(true)
|
178
|
-
|
179
|
-
described_class.new(config).poll_callback(data)
|
180
|
-
expect(config.performance_stats).to eq(true)
|
181
|
-
end
|
182
|
-
|
183
|
-
context "when error_host returns a value" do
|
184
|
-
it "sets the error_host option" do
|
185
|
-
config.error_host = 'http://api.airbrake.io'
|
186
|
-
allow(data).to receive(:error_host).and_return('https://api.example.com')
|
187
|
-
|
188
|
-
described_class.new(config).poll_callback(data)
|
189
|
-
expect(config.error_host).to eq('https://api.example.com')
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
context "when error_host returns nil" do
|
194
|
-
it "doesn't modify the error_host option" do
|
195
|
-
config.error_host = 'http://api.airbrake.io'
|
196
|
-
allow(data).to receive(:error_host).and_return(nil)
|
197
|
-
|
198
|
-
described_class.new(config).poll_callback(data)
|
199
|
-
expect(config.error_host).to eq('http://api.airbrake.io')
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
context "when apm_host returns a value" do
|
204
|
-
it "sets the apm_host option" do
|
205
|
-
config.apm_host = 'http://api.airbrake.io'
|
206
|
-
allow(data).to receive(:apm_host).and_return('https://api.example.com')
|
207
|
-
|
208
|
-
described_class.new(config).poll_callback(data)
|
209
|
-
expect(config.apm_host).to eq('https://api.example.com')
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
context "when apm_host returns nil" do
|
214
|
-
it "doesn't modify the apm_host option" do
|
215
|
-
config.apm_host = 'http://api.airbrake.io'
|
216
|
-
allow(data).to receive(:apm_host).and_return(nil)
|
217
|
-
|
218
|
-
described_class.new(config).poll_callback(data)
|
219
|
-
expect(config.apm_host).to eq('http://api.airbrake.io')
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
143
|
end
|