airbrake-ruby 5.0.0.rc.2 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) 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 +9 -35
  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_notifier.rb +1 -0
  21. data/lib/airbrake-ruby/performance_breakdown.rb +1 -6
  22. data/lib/airbrake-ruby/performance_notifier.rb +1 -14
  23. data/lib/airbrake-ruby/promise.rb +1 -0
  24. data/lib/airbrake-ruby/query.rb +1 -6
  25. data/lib/airbrake-ruby/queue.rb +1 -8
  26. data/lib/airbrake-ruby/remote_settings.rb +16 -54
  27. data/lib/airbrake-ruby/remote_settings/callback.rb +44 -0
  28. data/lib/airbrake-ruby/remote_settings/settings_data.rb +14 -14
  29. data/lib/airbrake-ruby/request.rb +1 -8
  30. data/lib/airbrake-ruby/stat.rb +1 -12
  31. data/lib/airbrake-ruby/sync_sender.rb +1 -0
  32. data/lib/airbrake-ruby/tdigest.rb +2 -0
  33. data/lib/airbrake-ruby/thread_pool.rb +1 -0
  34. data/lib/airbrake-ruby/truncator.rb +8 -2
  35. data/lib/airbrake-ruby/version.rb +2 -2
  36. data/spec/backtrace_spec.rb +26 -26
  37. data/spec/code_hunk_spec.rb +2 -2
  38. data/spec/config/processor_spec.rb +13 -102
  39. data/spec/config_spec.rb +4 -29
  40. data/spec/filters/gem_root_filter_spec.rb +4 -4
  41. data/spec/filters/git_last_checkout_filter_spec.rb +1 -1
  42. data/spec/filters/keys_allowlist_spec.rb +1 -0
  43. data/spec/filters/keys_blocklist_spec.rb +10 -0
  44. data/spec/filters/root_directory_filter_spec.rb +4 -4
  45. data/spec/filters/sql_filter_spec.rb +2 -2
  46. data/spec/notice_notifier/options_spec.rb +2 -2
  47. data/spec/notice_notifier_spec.rb +2 -2
  48. data/spec/notice_spec.rb +1 -1
  49. data/spec/performance_breakdown_spec.rb +0 -12
  50. data/spec/performance_notifier_spec.rb +0 -25
  51. data/spec/query_spec.rb +1 -11
  52. data/spec/queue_spec.rb +1 -13
  53. data/spec/remote_settings/callback_spec.rb +143 -0
  54. data/spec/remote_settings/settings_data_spec.rb +34 -13
  55. data/spec/remote_settings_spec.rb +40 -83
  56. data/spec/request_spec.rb +1 -13
  57. data/spec/spec_helper.rb +4 -4
  58. data/spec/stat_spec.rb +0 -9
  59. metadata +8 -5
@@ -1,9 +1,9 @@
1
1
  RSpec.describe Airbrake::RemoteSettings do
2
2
  let(:project_id) { 123 }
3
+ let(:host) { 'https://v1-production-notifier-configs.s3.amazonaws.com' }
3
4
 
4
5
  let(:endpoint) do
5
- "https://v1-staging-notifier-configs.s3.amazonaws.com/2020-06-18/config/" \
6
- "#{project_id}/config.json"
6
+ "#{host}/2020-06-18/config/#{project_id}/config.json"
7
7
  end
8
8
 
9
9
  let(:body) do
@@ -22,72 +22,34 @@ RSpec.describe Airbrake::RemoteSettings do
22
22
  }
23
23
  end
24
24
 
25
- let(:config_path) { described_class::CONFIG_DUMP_PATH }
26
- let(:config_dir) { File.dirname(config_path) }
27
-
28
25
  let!(:stub) do
29
26
  stub_request(:get, Regexp.new(endpoint))
30
27
  .to_return(status: 200, body: body.to_json)
31
28
  end
32
29
 
33
- before do
34
- # Do not create config dumps on disk.
35
- allow(Dir).to receive(:mkdir).with(config_dir)
36
- allow(File).to receive(:write).with(config_path, anything)
37
- end
38
-
39
30
  describe ".poll" do
40
31
  describe "config loading" do
41
32
  let(:settings_data) { described_class::SettingsData.new(project_id, body) }
42
33
 
43
34
  before do
44
- allow(File).to receive(:exist?).with(config_path).and_return(true)
45
- allow(File).to receive(:read).with(config_path).and_return(body.to_json)
46
-
47
35
  allow(described_class::SettingsData).to receive(:new).and_return(settings_data)
48
36
  end
49
37
 
50
- it "loads the config from disk" do
51
- expect(File).to receive(:read).with(config_path)
52
- expect(settings_data).to receive(:merge!).with(body).twice
53
-
54
- remote_settings = described_class.poll(project_id) {}
55
- sleep(0.2)
56
- remote_settings.stop_polling
57
-
58
- expect(stub).to have_been_requested.once
59
- end
60
-
61
38
  it "yields the config to the block twice" do
62
39
  block = proc {}
63
40
  expect(block).to receive(:call).twice
64
41
 
65
- remote_settings = described_class.poll(project_id, &block)
42
+ remote_settings = described_class.poll(project_id, host, &block)
66
43
  sleep(0.2)
67
44
  remote_settings.stop_polling
68
45
 
69
46
  expect(stub).to have_been_requested.once
70
47
  end
71
-
72
- context "when config loading fails" do
73
- it "logs an error" do
74
- expect(File).to receive(:read).and_raise(StandardError)
75
- expect(Airbrake::Loggable.instance).to receive(:error).with(
76
- '**Airbrake: config loading failed: StandardError',
77
- )
78
-
79
- remote_settings = described_class.poll(project_id) {}
80
- sleep(0.2)
81
- remote_settings.stop_polling
82
-
83
- expect(stub).to have_been_requested.once
84
- end
85
- end
86
48
  end
87
49
 
88
50
  context "when no errors are raised" do
89
51
  it "makes a request to AWS S3" do
90
- remote_settings = described_class.poll(project_id) {}
52
+ remote_settings = described_class.poll(project_id, host) {}
91
53
  sleep(0.1)
92
54
  remote_settings.stop_polling
93
55
 
@@ -95,7 +57,7 @@ RSpec.describe Airbrake::RemoteSettings do
95
57
  end
96
58
 
97
59
  it "sends params about the environment with the request" do
98
- remote_settings = described_class.poll(project_id) {}
60
+ remote_settings = described_class.poll(project_id, host) {}
99
61
  sleep(0.1)
100
62
  remote_settings.stop_polling
101
63
 
@@ -107,7 +69,7 @@ RSpec.describe Airbrake::RemoteSettings do
107
69
 
108
70
  it "fetches remote settings" do
109
71
  settings = nil
110
- remote_settings = described_class.poll(project_id) do |data|
72
+ remote_settings = described_class.poll(project_id, host) do |data|
111
73
  settings = data
112
74
  end
113
75
  sleep(0.1)
@@ -121,12 +83,12 @@ RSpec.describe Airbrake::RemoteSettings do
121
83
 
122
84
  context "when an error is raised while making a HTTP request" do
123
85
  before do
124
- allow(Net::HTTP).to receive(:get).and_raise(StandardError)
86
+ allow(Net::HTTP).to receive(:get_response).and_raise(StandardError)
125
87
  end
126
88
 
127
89
  it "doesn't fetch remote settings" do
128
90
  settings = nil
129
- remote_settings = described_class.poll(project_id) do |data|
91
+ remote_settings = described_class.poll(project_id, host) do |data|
130
92
  settings = data
131
93
  end
132
94
  sleep(0.1)
@@ -144,7 +106,7 @@ RSpec.describe Airbrake::RemoteSettings do
144
106
 
145
107
  it "doesn't update settings data" do
146
108
  settings = nil
147
- remote_settings = described_class.poll(project_id) do |data|
109
+ remote_settings = described_class.poll(project_id, host) do |data|
148
110
  settings = data
149
111
  end
150
112
  sleep(0.1)
@@ -155,15 +117,15 @@ RSpec.describe Airbrake::RemoteSettings do
155
117
  end
156
118
  end
157
119
 
158
- context "when API returns an XML response" do
120
+ context "when API returns a non-200 response" do
159
121
  let!(:stub) do
160
122
  stub_request(:get, Regexp.new(endpoint))
161
- .to_return(status: 200, body: '<?xml ...')
123
+ .to_return(status: 201, body: body.to_json)
162
124
  end
163
125
 
164
126
  it "doesn't update settings data" do
165
127
  settings = nil
166
- remote_settings = described_class.poll(project_id) do |data|
128
+ remote_settings = described_class.poll(project_id, host) do |data|
167
129
  settings = data
168
130
  end
169
131
  sleep(0.1)
@@ -172,58 +134,53 @@ RSpec.describe Airbrake::RemoteSettings do
172
134
  expect(stub).to have_been_requested.once
173
135
  expect(settings.interval).to eq(600)
174
136
  end
175
- end
176
137
 
177
- context "when a config route is specified in the returned data" do
178
- let(:new_endpoint) do
179
- "http://example.com"
180
- end
138
+ it "logs error" do
139
+ expect(Airbrake::Loggable.instance).to receive(:error).with(body.to_json)
181
140
 
182
- let(:body) do
183
- { 'config_route' => new_endpoint, 'poll_sec' => 0.1 }
141
+ remote_settings = described_class.poll(project_id, host) {}
142
+ sleep(0.1)
143
+ remote_settings.stop_polling
184
144
  end
145
+ end
185
146
 
186
- let!(:new_stub) do
187
- stub_request(:get, Regexp.new(new_endpoint))
147
+ context "when API returns a 200 response" do
148
+ let!(:stub) do
149
+ stub_request(:get, Regexp.new(endpoint))
188
150
  .to_return(status: 200, body: body.to_json)
189
151
  end
190
152
 
191
- it "makes the next request to the specified config route" do
192
- remote_settings = described_class.poll(project_id) {}
193
- sleep(0.2)
153
+ it "doesn't log errors" do
154
+ expect(Airbrake::Loggable.instance).not_to receive(:error)
194
155
 
156
+ remote_settings = described_class.poll(project_id, host) {}
157
+ sleep(0.1)
195
158
  remote_settings.stop_polling
196
-
197
- expect(stub).to have_been_requested.once
198
- expect(new_stub).to have_been_requested.once
199
159
  end
200
160
  end
201
- end
202
-
203
- describe "#stop_polling" do
204
- it "dumps config data to disk" do
205
- expect(Dir).to receive(:mkdir).with(config_dir)
206
- expect(File).to receive(:write).with(config_path, body.to_json)
207
161
 
208
- remote_settings = described_class.poll(project_id) {}
209
- sleep(0.2)
210
- remote_settings.stop_polling
162
+ context "when a config route is specified in the returned data" do
163
+ let(:new_config_route) do
164
+ '213/config/111/config.json'
165
+ end
211
166
 
212
- expect(stub).to have_been_requested.once
213
- end
167
+ let(:body) do
168
+ { 'config_route' => new_config_route, 'poll_sec' => 0.1 }
169
+ end
214
170
 
215
- context "when config dumping fails" do
216
- it "logs an error" do
217
- expect(File).to receive(:write).and_raise(StandardError)
218
- expect(Airbrake::Loggable.instance).to receive(:error).with(
219
- '**Airbrake: config dumping failed: StandardError',
220
- )
171
+ let!(:new_stub) do
172
+ stub_request(:get, Regexp.new(new_config_route))
173
+ .to_return(status: 200, body: body.to_json)
174
+ end
221
175
 
222
- remote_settings = described_class.poll(project_id) {}
176
+ it "makes the next request to the specified config route" do
177
+ remote_settings = described_class.poll(project_id, host) {}
223
178
  sleep(0.2)
179
+
224
180
  remote_settings.stop_polling
225
181
 
226
182
  expect(stub).to have_been_requested.once
183
+ expect(new_stub).to have_been_requested.once
227
184
  end
228
185
  end
229
186
  end
@@ -1,21 +1,9 @@
1
1
  RSpec.describe Airbrake::Request do
2
2
  describe "#stash" do
3
3
  subject do
4
- described_class.new(
5
- method: 'GET', route: '/', status_code: 200, start_time: Time.now,
6
- )
4
+ described_class.new(method: 'GET', route: '/', status_code: 200)
7
5
  end
8
6
 
9
7
  it { is_expected.to respond_to(:stash) }
10
8
  end
11
-
12
- describe "#end_time" do
13
- it "is always equal to start_time + 1 second by default" do
14
- time = Time.now
15
- request = described_class.new(
16
- method: 'GET', route: '/', status_code: 200, start_time: time,
17
- )
18
- expect(request.end_time).to eq(time + 1)
19
- end
20
- end
21
9
  end
@@ -33,7 +33,7 @@ class AirbrakeTestError < RuntimeError
33
33
 
34
34
  def initialize(*)
35
35
  super
36
- # rubocop:disable Metrics/LineLength
36
+ # rubocop:disable Layout/LineLength
37
37
  @backtrace = [
38
38
  "/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb:23:in `<top (required)>'",
39
39
  "/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'",
@@ -49,7 +49,7 @@ class AirbrakeTestError < RuntimeError
49
49
  "/home/kyrylo/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:41:in `invoke'",
50
50
  "/home/kyrylo/.gem/ruby/2.2.2/gems/rspec-core-3.3.2/exe/rspec:4:in `<main>'",
51
51
  ]
52
- # rubocop:enable Metrics/LineLength
52
+ # rubocop:enable Layout/LineLength
53
53
  end
54
54
 
55
55
  # rubocop:disable Naming/AccessorMethodName
@@ -66,7 +66,7 @@ end
66
66
  class JavaAirbrakeTestError < AirbrakeTestError
67
67
  def initialize(*)
68
68
  super
69
- # rubocop:disable Metrics/LineLength
69
+ # rubocop:disable Layout/LineLength
70
70
  @backtrace = [
71
71
  "org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:26)",
72
72
  "org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL(Interpreter.java:126)",
@@ -80,7 +80,7 @@ class JavaAirbrakeTestError < AirbrakeTestError
80
80
  "org.jruby.Main.run(Main.java:225)",
81
81
  "org.jruby.Main.main(Main.java:197)",
82
82
  ]
83
- # rubocop:enable Metrics/LineLength
83
+ # rubocop:enable Layout/LineLength
84
84
  end
85
85
 
86
86
  def is_a?(*)
@@ -10,15 +10,6 @@ RSpec.describe Airbrake::Stat do
10
10
  end
11
11
  end
12
12
 
13
- describe "#increment" do
14
- let(:start_time) { Time.new(2018, 1, 1, 0, 0, 20, 0) }
15
- let(:end_time) { Time.new(2018, 1, 1, 0, 0, 22, 0) }
16
-
17
- before { subject.increment(start_time, end_time) }
18
-
19
- its(:sum) { is_expected.to eq(2000) }
20
- end
21
-
22
13
  describe "#increment_ms" do
23
14
  before { subject.increment_ms(1000) }
24
15
 
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: 5.0.0.rc.2
4
+ version: 5.1.1
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: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree3
@@ -79,6 +79,7 @@ files:
79
79
  - lib/airbrake-ruby/query.rb
80
80
  - lib/airbrake-ruby/queue.rb
81
81
  - lib/airbrake-ruby/remote_settings.rb
82
+ - lib/airbrake-ruby/remote_settings/callback.rb
82
83
  - lib/airbrake-ruby/remote_settings/settings_data.rb
83
84
  - lib/airbrake-ruby/request.rb
84
85
  - lib/airbrake-ruby/response.rb
@@ -135,6 +136,7 @@ files:
135
136
  - spec/promise_spec.rb
136
137
  - spec/query_spec.rb
137
138
  - spec/queue_spec.rb
139
+ - spec/remote_settings/callback_spec.rb
138
140
  - spec/remote_settings/settings_data_spec.rb
139
141
  - spec/remote_settings_spec.rb
140
142
  - spec/request_spec.rb
@@ -160,12 +162,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
162
  requirements:
161
163
  - - ">="
162
164
  - !ruby/object:Gem::Version
163
- version: '2.1'
165
+ version: '2.3'
164
166
  required_rubygems_version: !ruby/object:Gem::Requirement
165
167
  requirements:
166
- - - ">"
168
+ - - ">="
167
169
  - !ruby/object:Gem::Version
168
- version: 1.3.1
170
+ version: '0'
169
171
  requirements: []
170
172
  rubygems_version: 3.1.2
171
173
  signing_key:
@@ -215,6 +217,7 @@ test_files:
215
217
  - spec/notice_notifier/options_spec.rb
216
218
  - spec/filter_chain_spec.rb
217
219
  - spec/remote_settings/settings_data_spec.rb
220
+ - spec/remote_settings/callback_spec.rb
218
221
  - spec/response_spec.rb
219
222
  - spec/queue_spec.rb
220
223
  - spec/code_hunk_spec.rb