airbrake-ruby 5.0.0.rc.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/airbrake-ruby.rb +1 -0
  3. data/lib/airbrake-ruby/backtrace.rb +6 -5
  4. data/lib/airbrake-ruby/config.rb +8 -36
  5. data/lib/airbrake-ruby/config/processor.rb +7 -17
  6. data/lib/airbrake-ruby/config/validator.rb +2 -0
  7. data/lib/airbrake-ruby/file_cache.rb +1 -1
  8. data/lib/airbrake-ruby/filter_chain.rb +1 -0
  9. data/lib/airbrake-ruby/filters/dependency_filter.rb +1 -0
  10. data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
  11. data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +1 -2
  12. data/lib/airbrake-ruby/filters/git_repository_filter.rb +3 -0
  13. data/lib/airbrake-ruby/filters/git_revision_filter.rb +2 -0
  14. data/lib/airbrake-ruby/filters/keys_filter.rb +21 -13
  15. data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
  16. data/lib/airbrake-ruby/filters/sql_filter.rb +4 -4
  17. data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
  18. data/lib/airbrake-ruby/filters/thread_filter.rb +2 -0
  19. data/lib/airbrake-ruby/ignorable.rb +1 -0
  20. data/lib/airbrake-ruby/notice.rb +1 -8
  21. data/lib/airbrake-ruby/notice_notifier.rb +1 -0
  22. data/lib/airbrake-ruby/performance_breakdown.rb +1 -6
  23. data/lib/airbrake-ruby/performance_notifier.rb +1 -14
  24. data/lib/airbrake-ruby/promise.rb +1 -0
  25. data/lib/airbrake-ruby/query.rb +1 -6
  26. data/lib/airbrake-ruby/queue.rb +1 -8
  27. data/lib/airbrake-ruby/remote_settings.rb +20 -44
  28. data/lib/airbrake-ruby/remote_settings/callback.rb +44 -0
  29. data/lib/airbrake-ruby/remote_settings/settings_data.rb +14 -14
  30. data/lib/airbrake-ruby/request.rb +1 -8
  31. data/lib/airbrake-ruby/stat.rb +1 -12
  32. data/lib/airbrake-ruby/sync_sender.rb +2 -1
  33. data/lib/airbrake-ruby/tdigest.rb +2 -0
  34. data/lib/airbrake-ruby/thread_pool.rb +1 -0
  35. data/lib/airbrake-ruby/truncator.rb +8 -2
  36. data/lib/airbrake-ruby/version.rb +11 -1
  37. data/spec/backtrace_spec.rb +26 -26
  38. data/spec/code_hunk_spec.rb +2 -2
  39. data/spec/config/processor_spec.rb +13 -102
  40. data/spec/config_spec.rb +4 -29
  41. data/spec/filters/gem_root_filter_spec.rb +4 -4
  42. data/spec/filters/git_last_checkout_filter_spec.rb +1 -1
  43. data/spec/filters/keys_allowlist_spec.rb +1 -0
  44. data/spec/filters/keys_blocklist_spec.rb +10 -0
  45. data/spec/filters/root_directory_filter_spec.rb +4 -4
  46. data/spec/filters/sql_filter_spec.rb +2 -2
  47. data/spec/notice_notifier/options_spec.rb +2 -2
  48. data/spec/notice_notifier_spec.rb +2 -2
  49. data/spec/notice_spec.rb +1 -1
  50. data/spec/performance_breakdown_spec.rb +0 -12
  51. data/spec/performance_notifier_spec.rb +0 -25
  52. data/spec/query_spec.rb +1 -11
  53. data/spec/queue_spec.rb +1 -13
  54. data/spec/remote_settings/callback_spec.rb +143 -0
  55. data/spec/remote_settings/settings_data_spec.rb +34 -13
  56. data/spec/remote_settings_spec.rb +40 -88
  57. data/spec/request_spec.rb +1 -13
  58. data/spec/spec_helper.rb +4 -4
  59. data/spec/stat_spec.rb +0 -9
  60. metadata +11 -8
@@ -9,7 +9,7 @@ module Airbrake
9
9
  #
10
10
  # @example
11
11
  # stat = Airbrake::Stat.new
12
- # stat.increment(Time.now - 200)
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
@@ -47,6 +47,7 @@ module Airbrake
47
47
  end
48
48
 
49
49
  return promise.reject(parsed_resp['error']) if parsed_resp.key?('error')
50
+
50
51
  promise.resolve(parsed_resp)
51
52
  end
52
53
 
@@ -79,7 +80,7 @@ module Airbrake
79
80
  req['Authorization'] = "Bearer #{@config.project_key}"
80
81
  req['Content-Type'] = CONTENT_TYPE
81
82
  req['User-Agent'] =
82
- "#{Airbrake::Notice::NOTIFIER[:name]}/#{Airbrake::AIRBRAKE_RUBY_VERSION}" \
83
+ "#{Airbrake::NOTIFIER_INFO[:name]}/#{Airbrake::AIRBRAKE_RUBY_VERSION}" \
83
84
  " Ruby/#{RUBY_VERSION}"
84
85
 
85
86
  req
@@ -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
@@ -129,6 +129,7 @@ module Airbrake
129
129
  Thread.new do
130
130
  while (message = @queue.pop)
131
131
  break if message == :stop
132
+
132
133
  @block.call(message)
133
134
  end
134
135
  end
@@ -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
- encoding = str.encoding
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
@@ -2,5 +2,15 @@
2
2
  # More information: http://semver.org/
3
3
  module Airbrake
4
4
  # @return [String] the library version
5
- AIRBRAKE_RUBY_VERSION = '5.0.0.rc.1'.freeze
5
+ # @api public
6
+ AIRBRAKE_RUBY_VERSION = '5.1.0'.freeze
7
+
8
+ # @return [Hash{Symbol=>String}] the information about the notifier library
9
+ # @since 5.0.0
10
+ # @api public
11
+ NOTIFIER_INFO = {
12
+ name: 'airbrake-ruby'.freeze,
13
+ version: Airbrake::AIRBRAKE_RUBY_VERSION,
14
+ url: 'https://github.com/airbrake/airbrake-ruby'.freeze,
15
+ }.freeze
6
16
  end
@@ -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 Metrics/LineLength, Style/HashSyntax, Layout/SpaceAroundOperators, Layout/SpaceInsideHashLiteralBraces
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 Metrics/LineLength, Style/HashSyntax, Layout/SpaceAroundOperators, Layout/SpaceInsideHashLiteralBraces
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 Metrics/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
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 Metrics/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
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 Metrics/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
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 Metrics/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
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 Metrics/LineLength
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 Metrics/LineLength
80
+ # rubocop:enable Layout/LineLength
81
81
  end
82
82
 
83
83
  let(:parsed_backtrace) do
84
- # rubocop:disable Metrics/LineLength
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 Metrics/LineLength
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 Metrics/LineLength
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 Metrics/LineLength
106
+ # rubocop:enable Layout/LineLength
107
107
  end
108
108
 
109
109
  let(:parsed_backtrace) do
110
- # rubocop:disable Metrics/LineLength
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 Metrics/LineLength
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 Metrics/LineLength
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 Metrics/LineLength
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 Metrics/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
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 Metrics/LineLength, Style/HashSyntax, Layout/SpaceInsideHashLiteralBraces, Layout/SpaceAroundOperators
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 Metrics/LineLength,Lint/InterpolationCheck
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 Metrics/LineLength,Lint/InterpolationCheck
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 Metrics/LineLength,Lint/InterpolationCheck
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 Metrics/LineLength,Lint/InterpolationCheck
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 Metrics/LineLength,Lint/InterpolationCheck
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 Metrics/LineLength,Lint/InterpolationCheck
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 Metrics/LineLength,Lint/InterpolationCheck
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 Metrics/LineLength,Lint/InterpolationCheck
375
+ # rubocop:enable Layout/LineLength,Lint/InterpolationCheck
376
376
  97 => ' else',
377
377
  },
378
378
  },
@@ -34,9 +34,9 @@ RSpec.describe Airbrake::CodeHunk do
34
34
  eq(
35
35
  1 => 'module Airbrake',
36
36
  2 => ' ##',
37
- # rubocop:disable Metrics/LineLength
37
+ # rubocop:disable Layout/LineLength
38
38
  3 => ' # Represents a chunk of information that is meant to be either sent to',
39
- # rubocop:enable Metrics/LineLength
39
+ # rubocop:enable Layout/LineLength
40
40
  ),
41
41
  )
42
42
  end
@@ -53,27 +53,23 @@ RSpec.describe Airbrake::Config::Processor do
53
53
  end
54
54
  end
55
55
 
56
- context "when the config defines a project_id" do
57
- context "and when remote configuration is false" do
58
- let(:config) do
59
- Airbrake::Config.new(project_id: 123, __remote_configuration: false)
60
- end
56
+ context "when the config sets environment to 'test'" do
57
+ let(:config) { Airbrake::Config.new(project_id: 123, environment: 'test') }
61
58
 
62
- it "doesn't set remote settings" do
63
- expect(Airbrake::RemoteSettings).not_to receive(:poll)
64
- described_class.new(config).process_remote_configuration
65
- end
59
+ it "doesn't set remote settings" do
60
+ expect(Airbrake::RemoteSettings).not_to receive(:poll)
61
+ described_class.new(config).process_remote_configuration
66
62
  end
63
+ end
67
64
 
68
- context "and when remote configuration is true" do
69
- let(:config) do
70
- Airbrake::Config.new(project_id: 123, __remote_configuration: true)
71
- end
65
+ context "when the config defines a project_id" do
66
+ let(:config) do
67
+ Airbrake::Config.new(project_id: 123, environment: 'not-test')
68
+ end
72
69
 
73
- it "sets remote settings" do
74
- expect(Airbrake::RemoteSettings).to receive(:poll)
75
- described_class.new(config).process_remote_configuration
76
- end
70
+ it "sets remote settings" do
71
+ expect(Airbrake::RemoteSettings).to receive(:poll)
72
+ described_class.new(config).process_remote_configuration
77
73
  end
78
74
  end
79
75
  end
@@ -135,89 +131,4 @@ RSpec.describe Airbrake::Config::Processor do
135
131
  end
136
132
  end
137
133
  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
134
  end
@@ -26,7 +26,10 @@ RSpec.describe Airbrake::Config do
26
26
  its(:query_stats) { is_expected.to eq(true) }
27
27
  its(:job_stats) { is_expected.to eq(true) }
28
28
  its(:error_notifications) { is_expected.to eq(true) }
29
- its(:__remote_configuration) { is_expected.to eq(false) }
29
+
30
+ its(:remote_config_host) do
31
+ is_expected.to eq('https://v1-production-notifier-configs.s3.amazonaws.com')
32
+ end
30
33
 
31
34
  describe "#new" do
32
35
  context "when user config is passed" do
@@ -173,32 +176,4 @@ RSpec.describe Airbrake::Config do
173
176
  expect(subject.logger.level).to eq(Logger::WARN)
174
177
  end
175
178
  end
176
-
177
- describe "#blacklist_keys=" do
178
- before { allow(Kernel).to receive(:warn) }
179
-
180
- it "sets blocklist_keys instead" do
181
- subject.blacklist_keys = [1, 2, 3]
182
- expect(subject.blocklist_keys).to eq([1, 2, 3])
183
- end
184
-
185
- it "prints a warning" do
186
- expect(Kernel).to receive(:warn).with(/use blocklist_keys= instead/)
187
- subject.blacklist_keys = [1, 2, 3]
188
- end
189
- end
190
-
191
- describe "#whitelist_keys=" do
192
- before { allow(Kernel).to receive(:warn) }
193
-
194
- it "sets allowlist_keys instead" do
195
- subject.whitelist_keys = [1, 2, 3]
196
- expect(subject.allowlist_keys).to eq([1, 2, 3])
197
- end
198
-
199
- it "prints a warning" do
200
- expect(Kernel).to receive(:warn).with(/use allowlist_keys= instead/)
201
- subject.whitelist_keys = [1, 2, 3]
202
- end
203
- end
204
179
  end