airbrake-ruby 6.0.2 → 6.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/lib/airbrake-ruby/config/processor.rb +6 -0
  3. data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +1 -1
  4. data/lib/airbrake-ruby/filters/git_repository_filter.rb +7 -1
  5. data/lib/airbrake-ruby/nested_exception.rb +22 -1
  6. data/lib/airbrake-ruby/notice.rb +5 -3
  7. data/lib/airbrake-ruby/sync_sender.rb +2 -2
  8. data/lib/airbrake-ruby/version.rb +1 -1
  9. metadata +4 -122
  10. data/spec/airbrake_spec.rb +0 -522
  11. data/spec/async_sender_spec.rb +0 -65
  12. data/spec/backtrace_spec.rb +0 -430
  13. data/spec/benchmark_spec.rb +0 -35
  14. data/spec/code_hunk_spec.rb +0 -124
  15. data/spec/config/processor_spec.rb +0 -151
  16. data/spec/config/validator_spec.rb +0 -204
  17. data/spec/config_spec.rb +0 -188
  18. data/spec/context_spec.rb +0 -54
  19. data/spec/deploy_notifier_spec.rb +0 -50
  20. data/spec/file_cache_spec.rb +0 -35
  21. data/spec/filter_chain_spec.rb +0 -124
  22. data/spec/filters/context_filter_spec.rb +0 -32
  23. data/spec/filters/dependency_filter_spec.rb +0 -14
  24. data/spec/filters/exception_attributes_filter_spec.rb +0 -52
  25. data/spec/filters/gem_root_filter_spec.rb +0 -44
  26. data/spec/filters/git_last_checkout_filter_spec.rb +0 -61
  27. data/spec/filters/git_repository_filter.rb +0 -61
  28. data/spec/filters/git_revision_filter_spec.rb +0 -126
  29. data/spec/filters/keys_allowlist_spec.rb +0 -204
  30. data/spec/filters/keys_blocklist_spec.rb +0 -242
  31. data/spec/filters/root_directory_filter_spec.rb +0 -39
  32. data/spec/filters/sql_filter_spec.rb +0 -274
  33. data/spec/filters/system_exit_filter_spec.rb +0 -16
  34. data/spec/filters/thread_filter_spec.rb +0 -281
  35. data/spec/fixtures/notroot.txt +0 -7
  36. data/spec/fixtures/project_root/code.rb +0 -221
  37. data/spec/fixtures/project_root/empty_file.rb +0 -0
  38. data/spec/fixtures/project_root/long_line.txt +0 -1
  39. data/spec/fixtures/project_root/short_file.rb +0 -3
  40. data/spec/fixtures/project_root/vendor/bundle/ignored_file.rb +0 -5
  41. data/spec/helpers.rb +0 -9
  42. data/spec/ignorable_spec.rb +0 -14
  43. data/spec/inspectable_spec.rb +0 -45
  44. data/spec/loggable_spec.rb +0 -17
  45. data/spec/monotonic_time_spec.rb +0 -25
  46. data/spec/nested_exception_spec.rb +0 -73
  47. data/spec/notice_notifier/options_spec.rb +0 -269
  48. data/spec/notice_notifier_spec.rb +0 -361
  49. data/spec/notice_spec.rb +0 -300
  50. data/spec/performance_breakdown_spec.rb +0 -11
  51. data/spec/performance_notifier_spec.rb +0 -645
  52. data/spec/promise_spec.rb +0 -203
  53. data/spec/query_spec.rb +0 -11
  54. data/spec/queue_spec.rb +0 -18
  55. data/spec/remote_settings/callback_spec.rb +0 -162
  56. data/spec/remote_settings/settings_data_spec.rb +0 -348
  57. data/spec/remote_settings_spec.rb +0 -201
  58. data/spec/request_spec.rb +0 -9
  59. data/spec/response_spec.rb +0 -110
  60. data/spec/spec_helper.rb +0 -100
  61. data/spec/stashable_spec.rb +0 -23
  62. data/spec/stat_spec.rb +0 -39
  63. data/spec/sync_sender_spec.rb +0 -168
  64. data/spec/tdigest_spec.rb +0 -235
  65. data/spec/thread_pool_spec.rb +0 -196
  66. data/spec/time_truncate_spec.rb +0 -30
  67. data/spec/timed_trace_spec.rb +0 -127
  68. data/spec/truncator_spec.rb +0 -267
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0310134480c9c13f2e8ab87a4c616768c213b590f98edd38e9c9abbd539a7ba
4
- data.tar.gz: 6f5e8d2411eee4e18ff97ef7d89b3c4a1c8ebb3ba5ec14fafe24c25e850672b1
3
+ metadata.gz: bf054506d2927e93c5bb6d6050ff0b13dd6cef15c901243ad1e7f4871a4f8568
4
+ data.tar.gz: b054ea5189464b1ebf822812cb7192893fbf84ef085b57fdfca9ead3d3361c6d
5
5
  SHA512:
6
- metadata.gz: d6e19e37eca3e38af441560c044ac1472ab06a282c4d8b4873a4c8529b9fb9e9a70634a42b4d0d5fe668ba866649ee115942678e5bbfffa1f60373ccd66e964b
7
- data.tar.gz: f8b22c23d2534b1f4dc12dd1b5d8bf970504b297a61421cda6d496ec2f1143ac9eb031e2c1b033e8d8a24b94b634c2a17ea475f9ef13d482be08a419a54b1d98
6
+ metadata.gz: 3469e65f834026e9c67c0200d2eca1786f8ea566b620f0ebc4175687a1d8b1ce41563460edc4a0be622e0d2dc93eade382fca1770bcb31b3f221dc188f5e4362
7
+ data.tar.gz: ee6edd6c1a279ba33ca4e898198aff4147e07be36feb9aa165fd076668499a08cc41d8fc5158dff09ee9fc7d5732f0e5c87b4e3bc1ca57d39485651d0431082a
@@ -43,8 +43,14 @@ module Airbrake
43
43
  def process_remote_configuration
44
44
  return unless @config.remote_config
45
45
  return unless @project_id
46
+
47
+ # Never poll remote configuration in the test environment.
46
48
  return if @config.environment == 'test'
47
49
 
50
+ # If the current environment is ignored, don't try to poll remote
51
+ # configuration.
52
+ return if @config.ignore_environments.include?(@config.environment)
53
+
48
54
  RemoteSettings.poll(@project_id, @config.remote_config_host) do |data|
49
55
  @poll_callback.call(data)
50
56
  end
@@ -27,7 +27,7 @@ module Airbrake
27
27
  @git_path = File.join(root_directory, '.git')
28
28
  @weight = 116
29
29
  @last_checkout = nil
30
- @deploy_username = ENV['AIRBRAKE_DEPLOY_USERNAME']
30
+ @deploy_username = ENV.fetch('AIRBRAKE_DEPLOY_USERNAME', nil)
31
31
  end
32
32
 
33
33
  # @macro call_filter
@@ -49,7 +49,13 @@ module Airbrake
49
49
  def detect_git_version
50
50
  return unless which('git')
51
51
 
52
- Gem::Version.new(`git --version`.split[2])
52
+ begin
53
+ Gem::Version.new(`git --version`.split[2])
54
+ rescue Errno::EAGAIN
55
+ # Bugfix for the case when the system cannot allocate memory for
56
+ # a fork() call: https://github.com/airbrake/airbrake-ruby/issues/680
57
+ nil
58
+ end
53
59
  end
54
60
 
55
61
  # Cross-platform way to tell if an executable is accessible.
@@ -9,6 +9,18 @@ module Airbrake
9
9
  # can unwrap. Exceptions that have a longer cause chain will be ignored
10
10
  MAX_NESTED_EXCEPTIONS = 3
11
11
 
12
+ # On Ruby 3.1+, the error highlighting gem can produce messages that can
13
+ # span multiple lines. We don't display multiline error messages in the
14
+ # title of the notice in the Airbrake dashboard. Therefore, we want to strip
15
+ # out the higlighting part so that the errors look consistent. The full
16
+ # message with the exception will be attached to the notice body.
17
+ #
18
+ # @return [String]
19
+ RUBY_31_ERROR_HIGHLIGHTING_DIVIDER = "\n\n".freeze
20
+
21
+ # @return [Hash] the options for +String#encode+
22
+ ENCODING_OPTIONS = { invalid: :replace, undef: :replace }.freeze
23
+
12
24
  def initialize(exception)
13
25
  @exception = exception
14
26
  end
@@ -16,7 +28,7 @@ module Airbrake
16
28
  def as_json
17
29
  unwind_exceptions.map do |exception|
18
30
  { type: exception.class.name,
19
- message: exception.message,
31
+ message: message(exception),
20
32
  backtrace: Backtrace.parse(exception) }
21
33
  end
22
34
  end
@@ -34,5 +46,14 @@ module Airbrake
34
46
 
35
47
  exception_list
36
48
  end
49
+
50
+ def message(exception)
51
+ return unless (msg = exception.message)
52
+
53
+ msg
54
+ .encode(Encoding::UTF_8, **ENCODING_OPTIONS)
55
+ .split(RUBY_31_ERROR_HIGHLIGHTING_DIVIDER)
56
+ .first
57
+ end
37
58
  end
38
59
  end
@@ -49,16 +49,17 @@ module Airbrake
49
49
  # @api private
50
50
  def initialize(exception, params = {})
51
51
  @config = Airbrake::Config.instance
52
+ @truncator = Airbrake::Truncator.new(PAYLOAD_MAX_SIZE)
53
+
52
54
  @payload = {
53
55
  errors: NestedException.new(exception).as_json,
54
- context: context,
56
+ context: context(exception),
55
57
  environment: {
56
58
  program_name: $PROGRAM_NAME,
57
59
  },
58
60
  session: {},
59
61
  params: params,
60
62
  }
61
- @truncator = Airbrake::Truncator.new(PAYLOAD_MAX_SIZE)
62
63
 
63
64
  stash[:exception] = exception
64
65
  end
@@ -118,7 +119,7 @@ module Airbrake
118
119
 
119
120
  private
120
121
 
121
- def context
122
+ def context(exception)
122
123
  {
123
124
  version: @config.app_version,
124
125
  versions: @config.versions,
@@ -132,6 +133,7 @@ module Airbrake
132
133
  hostname: HOSTNAME,
133
134
 
134
135
  severity: DEFAULT_SEVERITY,
136
+ error_message: @truncator.truncate(exception.message),
135
137
  }.merge(CONTEXT).delete_if { |_key, val| val.nil? || val.empty? }
136
138
  end
137
139
 
@@ -80,8 +80,8 @@ module Airbrake
80
80
  req['Authorization'] = "Bearer #{@config.project_key}"
81
81
  req['Content-Type'] = CONTENT_TYPE
82
82
  req['User-Agent'] =
83
- "#{Airbrake::NOTIFIER_INFO[:name]}/#{Airbrake::AIRBRAKE_RUBY_VERSION}" \
84
- " Ruby/#{RUBY_VERSION}"
83
+ "#{Airbrake::NOTIFIER_INFO[:name]}/#{Airbrake::AIRBRAKE_RUBY_VERSION} " \
84
+ "Ruby/#{RUBY_VERSION}"
85
85
 
86
86
  req
87
87
  end
@@ -3,7 +3,7 @@
3
3
  module Airbrake
4
4
  # @return [String] the library version
5
5
  # @api public
6
- AIRBRAKE_RUBY_VERSION = '6.0.2'.freeze
6
+ AIRBRAKE_RUBY_VERSION = '6.1.2'.freeze
7
7
 
8
8
  # @return [Hash{Symbol=>String}] the information about the notifier library
9
9
  # @since v5.0.0
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: 6.0.2
4
+ version: 6.1.2
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: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree3
@@ -93,65 +93,6 @@ files:
93
93
  - lib/airbrake-ruby/timed_trace.rb
94
94
  - lib/airbrake-ruby/truncator.rb
95
95
  - lib/airbrake-ruby/version.rb
96
- - spec/airbrake_spec.rb
97
- - spec/async_sender_spec.rb
98
- - spec/backtrace_spec.rb
99
- - spec/benchmark_spec.rb
100
- - spec/code_hunk_spec.rb
101
- - spec/config/processor_spec.rb
102
- - spec/config/validator_spec.rb
103
- - spec/config_spec.rb
104
- - spec/context_spec.rb
105
- - spec/deploy_notifier_spec.rb
106
- - spec/file_cache_spec.rb
107
- - spec/filter_chain_spec.rb
108
- - spec/filters/context_filter_spec.rb
109
- - spec/filters/dependency_filter_spec.rb
110
- - spec/filters/exception_attributes_filter_spec.rb
111
- - spec/filters/gem_root_filter_spec.rb
112
- - spec/filters/git_last_checkout_filter_spec.rb
113
- - spec/filters/git_repository_filter.rb
114
- - spec/filters/git_revision_filter_spec.rb
115
- - spec/filters/keys_allowlist_spec.rb
116
- - spec/filters/keys_blocklist_spec.rb
117
- - spec/filters/root_directory_filter_spec.rb
118
- - spec/filters/sql_filter_spec.rb
119
- - spec/filters/system_exit_filter_spec.rb
120
- - spec/filters/thread_filter_spec.rb
121
- - spec/fixtures/notroot.txt
122
- - spec/fixtures/project_root/code.rb
123
- - spec/fixtures/project_root/empty_file.rb
124
- - spec/fixtures/project_root/long_line.txt
125
- - spec/fixtures/project_root/short_file.rb
126
- - spec/fixtures/project_root/vendor/bundle/ignored_file.rb
127
- - spec/helpers.rb
128
- - spec/ignorable_spec.rb
129
- - spec/inspectable_spec.rb
130
- - spec/loggable_spec.rb
131
- - spec/monotonic_time_spec.rb
132
- - spec/nested_exception_spec.rb
133
- - spec/notice_notifier/options_spec.rb
134
- - spec/notice_notifier_spec.rb
135
- - spec/notice_spec.rb
136
- - spec/performance_breakdown_spec.rb
137
- - spec/performance_notifier_spec.rb
138
- - spec/promise_spec.rb
139
- - spec/query_spec.rb
140
- - spec/queue_spec.rb
141
- - spec/remote_settings/callback_spec.rb
142
- - spec/remote_settings/settings_data_spec.rb
143
- - spec/remote_settings_spec.rb
144
- - spec/request_spec.rb
145
- - spec/response_spec.rb
146
- - spec/spec_helper.rb
147
- - spec/stashable_spec.rb
148
- - spec/stat_spec.rb
149
- - spec/sync_sender_spec.rb
150
- - spec/tdigest_spec.rb
151
- - spec/thread_pool_spec.rb
152
- - spec/time_truncate_spec.rb
153
- - spec/timed_trace_spec.rb
154
- - spec/truncator_spec.rb
155
96
  homepage: https://airbrake.io
156
97
  licenses:
157
98
  - MIT
@@ -172,67 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
113
  - !ruby/object:Gem::Version
173
114
  version: '0'
174
115
  requirements: []
175
- rubygems_version: 3.2.15
116
+ rubygems_version: 3.3.3
176
117
  signing_key:
177
118
  specification_version: 4
178
119
  summary: Ruby notifier for https://airbrake.io
179
- test_files:
180
- - spec/airbrake_spec.rb
181
- - spec/async_sender_spec.rb
182
- - spec/backtrace_spec.rb
183
- - spec/benchmark_spec.rb
184
- - spec/code_hunk_spec.rb
185
- - spec/config/processor_spec.rb
186
- - spec/config/validator_spec.rb
187
- - spec/config_spec.rb
188
- - spec/context_spec.rb
189
- - spec/deploy_notifier_spec.rb
190
- - spec/file_cache_spec.rb
191
- - spec/filter_chain_spec.rb
192
- - spec/filters/context_filter_spec.rb
193
- - spec/filters/dependency_filter_spec.rb
194
- - spec/filters/exception_attributes_filter_spec.rb
195
- - spec/filters/gem_root_filter_spec.rb
196
- - spec/filters/git_last_checkout_filter_spec.rb
197
- - spec/filters/git_repository_filter.rb
198
- - spec/filters/git_revision_filter_spec.rb
199
- - spec/filters/keys_allowlist_spec.rb
200
- - spec/filters/keys_blocklist_spec.rb
201
- - spec/filters/root_directory_filter_spec.rb
202
- - spec/filters/sql_filter_spec.rb
203
- - spec/filters/system_exit_filter_spec.rb
204
- - spec/filters/thread_filter_spec.rb
205
- - spec/fixtures/notroot.txt
206
- - spec/fixtures/project_root/code.rb
207
- - spec/fixtures/project_root/empty_file.rb
208
- - spec/fixtures/project_root/long_line.txt
209
- - spec/fixtures/project_root/short_file.rb
210
- - spec/fixtures/project_root/vendor/bundle/ignored_file.rb
211
- - spec/helpers.rb
212
- - spec/ignorable_spec.rb
213
- - spec/inspectable_spec.rb
214
- - spec/loggable_spec.rb
215
- - spec/monotonic_time_spec.rb
216
- - spec/nested_exception_spec.rb
217
- - spec/notice_notifier/options_spec.rb
218
- - spec/notice_notifier_spec.rb
219
- - spec/notice_spec.rb
220
- - spec/performance_breakdown_spec.rb
221
- - spec/performance_notifier_spec.rb
222
- - spec/promise_spec.rb
223
- - spec/query_spec.rb
224
- - spec/queue_spec.rb
225
- - spec/remote_settings/callback_spec.rb
226
- - spec/remote_settings/settings_data_spec.rb
227
- - spec/remote_settings_spec.rb
228
- - spec/request_spec.rb
229
- - spec/response_spec.rb
230
- - spec/spec_helper.rb
231
- - spec/stashable_spec.rb
232
- - spec/stat_spec.rb
233
- - spec/sync_sender_spec.rb
234
- - spec/tdigest_spec.rb
235
- - spec/thread_pool_spec.rb
236
- - spec/time_truncate_spec.rb
237
- - spec/timed_trace_spec.rb
238
- - spec/truncator_spec.rb
120
+ test_files: []