airbrake-ruby 4.8.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/airbrake-ruby.rb +132 -57
  3. data/lib/airbrake-ruby/async_sender.rb +7 -30
  4. data/lib/airbrake-ruby/backtrace.rb +8 -7
  5. data/lib/airbrake-ruby/benchmark.rb +1 -1
  6. data/lib/airbrake-ruby/code_hunk.rb +1 -1
  7. data/lib/airbrake-ruby/config.rb +59 -15
  8. data/lib/airbrake-ruby/config/processor.rb +71 -0
  9. data/lib/airbrake-ruby/config/validator.rb +9 -3
  10. data/lib/airbrake-ruby/deploy_notifier.rb +1 -1
  11. data/lib/airbrake-ruby/file_cache.rb +1 -1
  12. data/lib/airbrake-ruby/filter_chain.rb +16 -1
  13. data/lib/airbrake-ruby/filters/dependency_filter.rb +1 -0
  14. data/lib/airbrake-ruby/filters/exception_attributes_filter.rb +2 -2
  15. data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
  16. data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +5 -5
  17. data/lib/airbrake-ruby/filters/git_repository_filter.rb +3 -0
  18. data/lib/airbrake-ruby/filters/git_revision_filter.rb +2 -0
  19. data/lib/airbrake-ruby/filters/{keys_whitelist.rb → keys_allowlist.rb} +3 -3
  20. data/lib/airbrake-ruby/filters/{keys_blacklist.rb → keys_blocklist.rb} +3 -3
  21. data/lib/airbrake-ruby/filters/keys_filter.rb +39 -20
  22. data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
  23. data/lib/airbrake-ruby/filters/sql_filter.rb +7 -7
  24. data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
  25. data/lib/airbrake-ruby/filters/thread_filter.rb +5 -4
  26. data/lib/airbrake-ruby/grouppable.rb +12 -0
  27. data/lib/airbrake-ruby/ignorable.rb +1 -0
  28. data/lib/airbrake-ruby/inspectable.rb +2 -2
  29. data/lib/airbrake-ruby/loggable.rb +1 -1
  30. data/lib/airbrake-ruby/mergeable.rb +12 -0
  31. data/lib/airbrake-ruby/monotonic_time.rb +5 -0
  32. data/lib/airbrake-ruby/notice.rb +7 -14
  33. data/lib/airbrake-ruby/notice_notifier.rb +11 -3
  34. data/lib/airbrake-ruby/performance_breakdown.rb +16 -10
  35. data/lib/airbrake-ruby/performance_notifier.rb +80 -58
  36. data/lib/airbrake-ruby/promise.rb +1 -0
  37. data/lib/airbrake-ruby/query.rb +20 -15
  38. data/lib/airbrake-ruby/queue.rb +65 -0
  39. data/lib/airbrake-ruby/remote_settings.rb +105 -0
  40. data/lib/airbrake-ruby/remote_settings/callback.rb +44 -0
  41. data/lib/airbrake-ruby/remote_settings/settings_data.rb +116 -0
  42. data/lib/airbrake-ruby/request.rb +14 -12
  43. data/lib/airbrake-ruby/stat.rb +26 -33
  44. data/lib/airbrake-ruby/sync_sender.rb +3 -2
  45. data/lib/airbrake-ruby/tdigest.rb +43 -58
  46. data/lib/airbrake-ruby/thread_pool.rb +11 -1
  47. data/lib/airbrake-ruby/truncator.rb +10 -4
  48. data/lib/airbrake-ruby/version.rb +11 -1
  49. data/spec/airbrake_spec.rb +206 -71
  50. data/spec/async_sender_spec.rb +3 -12
  51. data/spec/backtrace_spec.rb +44 -44
  52. data/spec/code_hunk_spec.rb +11 -11
  53. data/spec/config/processor_spec.rb +143 -0
  54. data/spec/config/validator_spec.rb +23 -6
  55. data/spec/config_spec.rb +40 -14
  56. data/spec/deploy_notifier_spec.rb +2 -2
  57. data/spec/filter_chain_spec.rb +28 -1
  58. data/spec/filters/dependency_filter_spec.rb +1 -1
  59. data/spec/filters/gem_root_filter_spec.rb +9 -9
  60. data/spec/filters/git_last_checkout_filter_spec.rb +21 -4
  61. data/spec/filters/git_repository_filter.rb +1 -1
  62. data/spec/filters/git_revision_filter_spec.rb +10 -10
  63. data/spec/filters/{keys_whitelist_spec.rb → keys_allowlist_spec.rb} +29 -28
  64. data/spec/filters/{keys_blacklist_spec.rb → keys_blocklist_spec.rb} +39 -29
  65. data/spec/filters/root_directory_filter_spec.rb +9 -9
  66. data/spec/filters/sql_filter_spec.rb +58 -60
  67. data/spec/filters/system_exit_filter_spec.rb +1 -1
  68. data/spec/filters/thread_filter_spec.rb +32 -30
  69. data/spec/fixtures/project_root/code.rb +9 -9
  70. data/spec/loggable_spec.rb +17 -0
  71. data/spec/monotonic_time_spec.rb +11 -0
  72. data/spec/notice_notifier/options_spec.rb +17 -17
  73. data/spec/notice_notifier_spec.rb +20 -20
  74. data/spec/notice_spec.rb +6 -6
  75. data/spec/performance_breakdown_spec.rb +0 -1
  76. data/spec/performance_notifier_spec.rb +220 -73
  77. data/spec/query_spec.rb +1 -1
  78. data/spec/queue_spec.rb +18 -0
  79. data/spec/remote_settings/callback_spec.rb +143 -0
  80. data/spec/remote_settings/settings_data_spec.rb +348 -0
  81. data/spec/remote_settings_spec.rb +187 -0
  82. data/spec/request_spec.rb +1 -3
  83. data/spec/response_spec.rb +8 -8
  84. data/spec/spec_helper.rb +6 -6
  85. data/spec/stat_spec.rb +2 -12
  86. data/spec/sync_sender_spec.rb +14 -12
  87. data/spec/tdigest_spec.rb +7 -7
  88. data/spec/thread_pool_spec.rb +39 -10
  89. data/spec/timed_trace_spec.rb +1 -1
  90. data/spec/truncator_spec.rb +12 -12
  91. metadata +32 -14
@@ -7,7 +7,7 @@ RSpec.describe Airbrake::ThreadPool do
7
7
  described_class.new(
8
8
  worker_size: worker_size,
9
9
  queue_size: queue_size,
10
- block: proc { |message| tasks << message }
10
+ block: proc { |message| tasks << message },
11
11
  )
12
12
  end
13
13
 
@@ -35,7 +35,7 @@ RSpec.describe Airbrake::ThreadPool do
35
35
  described_class.new(
36
36
  worker_size: 1,
37
37
  queue_size: 1,
38
- block: proc { |message| tasks << message }
38
+ block: proc { |message| tasks << message },
39
39
  )
40
40
  end
41
41
 
@@ -51,6 +51,15 @@ RSpec.describe Airbrake::ThreadPool do
51
51
 
52
52
  expect(tasks.size).to be_zero
53
53
  end
54
+
55
+ it "logs discarded tasks" do
56
+ expect(Airbrake::Loggable.instance).to receive(:error).with(
57
+ /reached its capacity/,
58
+ ).exactly(15).times
59
+
60
+ 15.times { subject << 1 }
61
+ subject.close
62
+ end
54
63
  end
55
64
  end
56
65
 
@@ -76,11 +85,31 @@ RSpec.describe Airbrake::ThreadPool do
76
85
  expect(subject).not_to have_workers
77
86
  end
78
87
 
79
- it "respawns workers on fork()", skip: %w[jruby].include?(RUBY_ENGINE) do
80
- pid = fork { expect(subject).to have_workers }
81
- Process.wait(pid)
82
- subject.close
83
- 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
84
113
  end
85
114
  end
86
115
 
@@ -98,11 +127,11 @@ RSpec.describe Airbrake::ThreadPool do
98
127
  context "when there's some work to do" do
99
128
  it "logs how many tasks are left to process" do
100
129
  thread_pool = described_class.new(
101
- worker_size: 0, queue_size: 2, block: proc {}
130
+ worker_size: 0, queue_size: 2, block: proc {},
102
131
  )
103
132
 
104
133
  expect(Airbrake::Loggable.instance).to receive(:debug).with(
105
- /waiting to process \d+ task\(s\)/
134
+ /waiting to process \d+ task\(s\)/,
106
135
  )
107
136
  expect(Airbrake::Loggable.instance).to receive(:debug).with(/closed/)
108
137
 
@@ -112,7 +141,7 @@ RSpec.describe Airbrake::ThreadPool do
112
141
 
113
142
  it "waits until the queue gets empty" do
114
143
  thread_pool = described_class.new(
115
- worker_size: 1, queue_size: 2, block: proc {}
144
+ worker_size: 1, queue_size: 2, block: proc {},
116
145
  )
117
146
 
118
147
  10.times { subject << 1 }
@@ -117,7 +117,7 @@ RSpec.describe Airbrake::TimedTrace do
117
117
  it "returns a Hash with all spans" do
118
118
  expect(subject.spans).to match(
119
119
  'operation' => be > 0,
120
- 'another operation' => be > 0
120
+ 'another operation' => be > 0,
121
121
  )
122
122
  end
123
123
  end
@@ -25,7 +25,7 @@ RSpec.describe Airbrake::Truncator do
25
25
  banana: multiply_by_2_max_len('a'),
26
26
  kiwi: multiply_by_2_max_len('b'),
27
27
  strawberry: 'c',
28
- shrimp: 'd'
28
+ shrimp: 'd',
29
29
  }.freeze
30
30
  end
31
31
 
@@ -34,7 +34,7 @@ RSpec.describe Airbrake::Truncator do
34
34
  expect(subject).to be_frozen
35
35
 
36
36
  expect(subject).to eq(
37
- banana: 'aaa[Truncated]', kiwi: 'bbb[Truncated]', strawberry: 'c'
37
+ banana: 'aaa[Truncated]', kiwi: 'bbb[Truncated]', strawberry: 'c',
38
38
  )
39
39
  expect(subject[:banana]).to be_frozen
40
40
  expect(subject[:kiwi]).to be_frozen
@@ -48,7 +48,7 @@ RSpec.describe Airbrake::Truncator do
48
48
  multiply_by_2_max_len('a'),
49
49
  'b',
50
50
  multiply_by_2_max_len('c'),
51
- 'd'
51
+ 'd',
52
52
  ].freeze
53
53
  end
54
54
 
@@ -69,7 +69,7 @@ RSpec.describe Airbrake::Truncator do
69
69
  multiply_by_2_max_len('a'),
70
70
  'b',
71
71
  multiply_by_2_max_len('c'),
72
- 'd'
72
+ 'd',
73
73
  ]).freeze
74
74
  end
75
75
 
@@ -78,7 +78,7 @@ RSpec.describe Airbrake::Truncator do
78
78
  expect(subject).to be_frozen
79
79
 
80
80
  expect(subject).to eq(
81
- Set.new(['aaa[Truncated]', 'b', 'ccc[Truncated]'])
81
+ Set.new(['aaa[Truncated]', 'b', 'ccc[Truncated]']),
82
82
  )
83
83
  expect(subject).to be_frozen
84
84
  end
@@ -166,7 +166,7 @@ RSpec.describe Airbrake::Truncator do
166
166
 
167
167
  it "prevents recursion" do
168
168
  expect(subject).to eq(
169
- Set.new(['[Circular]', { k: '[Circular]' }, 'aaa[Truncated]'])
169
+ Set.new(['[Circular]', { k: '[Circular]' }, 'aaa[Truncated]']),
170
170
  )
171
171
  expect(subject).to be_frozen
172
172
  end
@@ -177,13 +177,13 @@ RSpec.describe Airbrake::Truncator do
177
177
  {
178
178
  a: multiply_by_2_max_len('a'),
179
179
  b: multiply_by_2_max_len('b'),
180
- c: { d: multiply_by_2_max_len('d'), e: 'e' }
180
+ c: { d: multiply_by_2_max_len('d'), e: 'e' },
181
181
  }
182
182
  end
183
183
 
184
184
  it "truncates the long strings" do
185
185
  expect(subject).to eq(
186
- a: 'aaa[Truncated]', b: 'bbb[Truncated]', c: { d: 'ddd[Truncated]', e: 'e' }
186
+ a: 'aaa[Truncated]', b: 'bbb[Truncated]', c: { d: 'ddd[Truncated]', e: 'e' },
187
187
  )
188
188
  expect(subject).to be_frozen
189
189
  end
@@ -218,8 +218,8 @@ RSpec.describe Airbrake::Truncator do
218
218
  errors: [
219
219
  { file: 'a' },
220
220
  { file: 'a' },
221
- hashie.new.merge(file: 'bcde')
222
- ]
221
+ hashie.new.merge(file: 'bcde'),
222
+ ],
223
223
  }
224
224
  end
225
225
 
@@ -228,8 +228,8 @@ RSpec.describe Airbrake::Truncator do
228
228
  errors: [
229
229
  { file: 'a' },
230
230
  { file: 'a' },
231
- hashie.new.merge(file: 'bcd[Truncated]')
232
- ]
231
+ hashie.new.merge(file: 'bcd[Truncated]'),
232
+ ],
233
233
  )
234
234
  expect(subject).to be_frozen
235
235
  end
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.8.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-23 00:00:00.000000000 Z
11
+ date: 2020-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree3
@@ -44,6 +44,7 @@ files:
44
44
  - lib/airbrake-ruby/benchmark.rb
45
45
  - lib/airbrake-ruby/code_hunk.rb
46
46
  - lib/airbrake-ruby/config.rb
47
+ - lib/airbrake-ruby/config/processor.rb
47
48
  - lib/airbrake-ruby/config/validator.rb
48
49
  - lib/airbrake-ruby/deploy_notifier.rb
49
50
  - lib/airbrake-ruby/file_cache.rb
@@ -55,17 +56,19 @@ files:
55
56
  - lib/airbrake-ruby/filters/git_last_checkout_filter.rb
56
57
  - lib/airbrake-ruby/filters/git_repository_filter.rb
57
58
  - lib/airbrake-ruby/filters/git_revision_filter.rb
58
- - lib/airbrake-ruby/filters/keys_blacklist.rb
59
+ - lib/airbrake-ruby/filters/keys_allowlist.rb
60
+ - lib/airbrake-ruby/filters/keys_blocklist.rb
59
61
  - lib/airbrake-ruby/filters/keys_filter.rb
60
- - lib/airbrake-ruby/filters/keys_whitelist.rb
61
62
  - lib/airbrake-ruby/filters/root_directory_filter.rb
62
63
  - lib/airbrake-ruby/filters/sql_filter.rb
63
64
  - lib/airbrake-ruby/filters/system_exit_filter.rb
64
65
  - lib/airbrake-ruby/filters/thread_filter.rb
66
+ - lib/airbrake-ruby/grouppable.rb
65
67
  - lib/airbrake-ruby/hash_keyable.rb
66
68
  - lib/airbrake-ruby/ignorable.rb
67
69
  - lib/airbrake-ruby/inspectable.rb
68
70
  - lib/airbrake-ruby/loggable.rb
71
+ - lib/airbrake-ruby/mergeable.rb
69
72
  - lib/airbrake-ruby/monotonic_time.rb
70
73
  - lib/airbrake-ruby/nested_exception.rb
71
74
  - lib/airbrake-ruby/notice.rb
@@ -74,6 +77,10 @@ files:
74
77
  - lib/airbrake-ruby/performance_notifier.rb
75
78
  - lib/airbrake-ruby/promise.rb
76
79
  - lib/airbrake-ruby/query.rb
80
+ - lib/airbrake-ruby/queue.rb
81
+ - lib/airbrake-ruby/remote_settings.rb
82
+ - lib/airbrake-ruby/remote_settings/callback.rb
83
+ - lib/airbrake-ruby/remote_settings/settings_data.rb
77
84
  - lib/airbrake-ruby/request.rb
78
85
  - lib/airbrake-ruby/response.rb
79
86
  - lib/airbrake-ruby/stashable.rb
@@ -90,6 +97,7 @@ files:
90
97
  - spec/backtrace_spec.rb
91
98
  - spec/benchmark_spec.rb
92
99
  - spec/code_hunk_spec.rb
100
+ - spec/config/processor_spec.rb
93
101
  - spec/config/validator_spec.rb
94
102
  - spec/config_spec.rb
95
103
  - spec/deploy_notifier_spec.rb
@@ -102,8 +110,8 @@ files:
102
110
  - spec/filters/git_last_checkout_filter_spec.rb
103
111
  - spec/filters/git_repository_filter.rb
104
112
  - spec/filters/git_revision_filter_spec.rb
105
- - spec/filters/keys_blacklist_spec.rb
106
- - spec/filters/keys_whitelist_spec.rb
113
+ - spec/filters/keys_allowlist_spec.rb
114
+ - spec/filters/keys_blocklist_spec.rb
107
115
  - spec/filters/root_directory_filter_spec.rb
108
116
  - spec/filters/sql_filter_spec.rb
109
117
  - spec/filters/system_exit_filter_spec.rb
@@ -117,6 +125,7 @@ files:
117
125
  - spec/helpers.rb
118
126
  - spec/ignorable_spec.rb
119
127
  - spec/inspectable_spec.rb
128
+ - spec/loggable_spec.rb
120
129
  - spec/monotonic_time_spec.rb
121
130
  - spec/nested_exception_spec.rb
122
131
  - spec/notice_notifier/options_spec.rb
@@ -126,6 +135,10 @@ files:
126
135
  - spec/performance_notifier_spec.rb
127
136
  - spec/promise_spec.rb
128
137
  - spec/query_spec.rb
138
+ - spec/queue_spec.rb
139
+ - spec/remote_settings/callback_spec.rb
140
+ - spec/remote_settings/settings_data_spec.rb
141
+ - spec/remote_settings_spec.rb
129
142
  - spec/request_spec.rb
130
143
  - spec/response_spec.rb
131
144
  - spec/spec_helper.rb
@@ -141,7 +154,7 @@ homepage: https://airbrake.io
141
154
  licenses:
142
155
  - MIT
143
156
  metadata: {}
144
- post_install_message:
157
+ post_install_message:
145
158
  rdoc_options: []
146
159
  require_paths:
147
160
  - lib
@@ -149,16 +162,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
162
  requirements:
150
163
  - - ">="
151
164
  - !ruby/object:Gem::Version
152
- version: '2.1'
165
+ version: '2.3'
153
166
  required_rubygems_version: !ruby/object:Gem::Requirement
154
167
  requirements:
155
168
  - - ">="
156
169
  - !ruby/object:Gem::Version
157
170
  version: '0'
158
171
  requirements: []
159
- rubyforge_project:
160
- rubygems_version: 2.7.6.2
161
- signing_key:
172
+ rubygems_version: 3.1.2
173
+ signing_key:
162
174
  specification_version: 4
163
175
  summary: Ruby notifier for https://airbrake.io
164
176
  test_files:
@@ -168,14 +180,14 @@ test_files:
168
180
  - spec/filters/exception_attributes_filter_spec.rb
169
181
  - spec/filters/root_directory_filter_spec.rb
170
182
  - spec/filters/sql_filter_spec.rb
171
- - spec/filters/keys_whitelist_spec.rb
172
183
  - spec/filters/system_exit_filter_spec.rb
173
184
  - spec/filters/thread_filter_spec.rb
185
+ - spec/filters/keys_allowlist_spec.rb
174
186
  - spec/filters/dependency_filter_spec.rb
175
187
  - spec/filters/context_filter_spec.rb
176
188
  - spec/filters/git_last_checkout_filter_spec.rb
177
189
  - spec/filters/git_revision_filter_spec.rb
178
- - spec/filters/keys_blacklist_spec.rb
190
+ - spec/filters/keys_blocklist_spec.rb
179
191
  - spec/filters/gem_root_filter_spec.rb
180
192
  - spec/filters/git_repository_filter.rb
181
193
  - spec/spec_helper.rb
@@ -185,12 +197,14 @@ test_files:
185
197
  - spec/tdigest_spec.rb
186
198
  - spec/async_sender_spec.rb
187
199
  - spec/stat_spec.rb
200
+ - spec/loggable_spec.rb
188
201
  - spec/backtrace_spec.rb
189
202
  - spec/notice_notifier_spec.rb
190
203
  - spec/time_truncate_spec.rb
191
204
  - spec/promise_spec.rb
192
205
  - spec/thread_pool_spec.rb
193
206
  - spec/config/validator_spec.rb
207
+ - spec/config/processor_spec.rb
194
208
  - spec/sync_sender_spec.rb
195
209
  - spec/ignorable_spec.rb
196
210
  - spec/deploy_notifier_spec.rb
@@ -202,7 +216,10 @@ test_files:
202
216
  - spec/request_spec.rb
203
217
  - spec/notice_notifier/options_spec.rb
204
218
  - spec/filter_chain_spec.rb
219
+ - spec/remote_settings/settings_data_spec.rb
220
+ - spec/remote_settings/callback_spec.rb
205
221
  - spec/response_spec.rb
222
+ - spec/queue_spec.rb
206
223
  - spec/code_hunk_spec.rb
207
224
  - spec/fixtures/notroot.txt
208
225
  - spec/fixtures/project_root/long_line.txt
@@ -214,3 +231,4 @@ test_files:
214
231
  - spec/inspectable_spec.rb
215
232
  - spec/stashable_spec.rb
216
233
  - spec/query_spec.rb
234
+ - spec/remote_settings_spec.rb