airbrake-ruby 5.0.0.rc.1-java → 5.1.1-java

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 +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.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 +26 -49
  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 +62 -87
  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
@@ -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://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,15 +22,9 @@ 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
- before do
29
- stub_request(:get, endpoint).to_return(status: 200, body: body.to_json)
30
-
31
- # Do not create config dumps on disk.
32
- allow(Dir).to receive(:mkdir).with(config_dir)
33
- allow(File).to receive(:write).with(config_path, anything)
25
+ let!(:stub) do
26
+ stub_request(:get, Regexp.new(endpoint))
27
+ .to_return(status: 200, body: body.to_json)
34
28
  end
35
29
 
36
30
  describe ".poll" do
@@ -38,62 +32,44 @@ RSpec.describe Airbrake::RemoteSettings do
38
32
  let(:settings_data) { described_class::SettingsData.new(project_id, body) }
39
33
 
40
34
  before do
41
- allow(File).to receive(:exist?).with(config_path).and_return(true)
42
- allow(File).to receive(:read).with(config_path).and_return(body.to_json)
43
-
44
35
  allow(described_class::SettingsData).to receive(:new).and_return(settings_data)
45
36
  end
46
37
 
47
- it "loads the config from disk" do
48
- expect(File).to receive(:read).with(config_path)
49
- expect(settings_data).to receive(:merge!).with(body).twice
50
-
51
- remote_settings = described_class.poll(project_id) {}
52
- sleep(0.2)
53
- remote_settings.stop_polling
54
-
55
- expect(a_request(:get, endpoint)).to have_been_made.once
56
- end
57
-
58
38
  it "yields the config to the block twice" do
59
39
  block = proc {}
60
40
  expect(block).to receive(:call).twice
61
41
 
62
- remote_settings = described_class.poll(project_id, &block)
42
+ remote_settings = described_class.poll(project_id, host, &block)
63
43
  sleep(0.2)
64
44
  remote_settings.stop_polling
65
45
 
66
- expect(a_request(:get, endpoint)).to have_been_made.once
67
- end
68
-
69
- context "when config loading fails" do
70
- it "logs an error" do
71
- expect(File).to receive(:read).and_raise(StandardError)
72
- expect(Airbrake::Loggable.instance).to receive(:error).with(
73
- '**Airbrake: config loading failed: StandardError',
74
- )
75
-
76
- remote_settings = described_class.poll(project_id) {}
77
- sleep(0.2)
78
- remote_settings.stop_polling
79
-
80
- expect(a_request(:get, endpoint)).to have_been_made.once
81
- end
46
+ expect(stub).to have_been_requested.once
82
47
  end
83
48
  end
84
49
 
85
50
  context "when no errors are raised" do
86
51
  it "makes a request to AWS S3" do
87
- remote_settings = described_class.poll(project_id) {}
52
+ remote_settings = described_class.poll(project_id, host) {}
88
53
  sleep(0.1)
89
54
  remote_settings.stop_polling
90
55
 
91
- expect(a_request(:get, endpoint)).to have_been_made.at_least_once
56
+ expect(stub).to have_been_requested.at_least_once
57
+ end
58
+
59
+ it "sends params about the environment with the request" do
60
+ remote_settings = described_class.poll(project_id, host) {}
61
+ sleep(0.1)
62
+ remote_settings.stop_polling
63
+
64
+ stub_with_query_params = stub.with(
65
+ query: URI.decode_www_form(described_class::QUERY_PARAMS).to_h,
66
+ )
67
+ expect(stub_with_query_params).to have_been_requested.at_least_once
92
68
  end
93
69
 
94
70
  it "fetches remote settings" do
95
71
  settings = nil
96
- remote_settings = described_class.poll(project_id) do |data|
72
+ remote_settings = described_class.poll(project_id, host) do |data|
97
73
  settings = data
98
74
  end
99
75
  sleep(0.1)
@@ -107,18 +83,18 @@ RSpec.describe Airbrake::RemoteSettings do
107
83
 
108
84
  context "when an error is raised while making a HTTP request" do
109
85
  before do
110
- allow(Net::HTTP).to receive(:get).and_raise(StandardError)
86
+ allow(Net::HTTP).to receive(:get_response).and_raise(StandardError)
111
87
  end
112
88
 
113
89
  it "doesn't fetch remote settings" do
114
90
  settings = nil
115
- remote_settings = described_class.poll(project_id) do |data|
91
+ remote_settings = described_class.poll(project_id, host) do |data|
116
92
  settings = data
117
93
  end
118
94
  sleep(0.1)
119
95
  remote_settings.stop_polling
120
96
 
121
- expect(a_request(:get, endpoint)).not_to have_been_made
97
+ expect(stub).not_to have_been_requested
122
98
  expect(settings.interval).to eq(600)
123
99
  end
124
100
  end
@@ -130,82 +106,81 @@ RSpec.describe Airbrake::RemoteSettings do
130
106
 
131
107
  it "doesn't update settings data" do
132
108
  settings = nil
133
- remote_settings = described_class.poll(project_id) do |data|
109
+ remote_settings = described_class.poll(project_id, host) do |data|
134
110
  settings = data
135
111
  end
136
112
  sleep(0.1)
137
113
  remote_settings.stop_polling
138
114
 
139
- expect(a_request(:get, endpoint)).to have_been_made.once
115
+ expect(stub).to have_been_requested.once
140
116
  expect(settings.interval).to eq(600)
141
117
  end
142
118
  end
143
119
 
144
- context "when API returns an XML response" do
145
- before do
146
- stub_request(:get, endpoint).to_return(status: 200, body: '<?xml ...')
120
+ context "when API returns a non-200 response" do
121
+ let!(:stub) do
122
+ stub_request(:get, Regexp.new(endpoint))
123
+ .to_return(status: 201, body: body.to_json)
147
124
  end
148
125
 
149
126
  it "doesn't update settings data" do
150
127
  settings = nil
151
- remote_settings = described_class.poll(project_id) do |data|
128
+ remote_settings = described_class.poll(project_id, host) do |data|
152
129
  settings = data
153
130
  end
154
131
  sleep(0.1)
155
132
  remote_settings.stop_polling
156
133
 
157
- expect(a_request(:get, endpoint)).to have_been_made.once
134
+ expect(stub).to have_been_requested.once
158
135
  expect(settings.interval).to eq(600)
159
136
  end
160
- end
161
137
 
162
- context "when a config route is specified in the returned data" do
163
- let(:new_endpoint) { 'http://example.com' }
138
+ it "logs error" do
139
+ expect(Airbrake::Loggable.instance).to receive(:error).with(body.to_json)
164
140
 
165
- let(:body) do
166
- { '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
167
144
  end
145
+ end
168
146
 
169
- before do
170
- stub_request(:get, new_endpoint).to_return(status: 200, body: body.to_json)
147
+ context "when API returns a 200 response" do
148
+ let!(:stub) do
149
+ stub_request(:get, Regexp.new(endpoint))
150
+ .to_return(status: 200, body: body.to_json)
171
151
  end
172
152
 
173
- it "makes the next request to the specified config route" do
174
- remote_settings = described_class.poll(project_id) {}
175
- sleep(0.2)
153
+ it "doesn't log errors" do
154
+ expect(Airbrake::Loggable.instance).not_to receive(:error)
176
155
 
156
+ remote_settings = described_class.poll(project_id, host) {}
157
+ sleep(0.1)
177
158
  remote_settings.stop_polling
178
-
179
- expect(a_request(:get, endpoint)).to have_been_made.once
180
- expect(a_request(:get, new_endpoint)).to have_been_made.once
181
159
  end
182
160
  end
183
- end
184
161
 
185
- describe "#stop_polling" do
186
- it "dumps config data to disk" do
187
- expect(Dir).to receive(:mkdir).with(config_dir)
188
- expect(File).to receive(:write).with(config_path, body.to_json)
189
-
190
- remote_settings = described_class.poll(project_id) {}
191
- sleep(0.2)
192
- 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
193
166
 
194
- expect(a_request(:get, endpoint)).to have_been_made.once
195
- end
167
+ let(:body) do
168
+ { 'config_route' => new_config_route, 'poll_sec' => 0.1 }
169
+ end
196
170
 
197
- context "when config dumping fails" do
198
- it "logs an error" do
199
- expect(File).to receive(:write).and_raise(StandardError)
200
- expect(Airbrake::Loggable.instance).to receive(:error).with(
201
- '**Airbrake: config dumping failed: StandardError',
202
- )
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
203
175
 
204
- 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) {}
205
178
  sleep(0.2)
179
+
206
180
  remote_settings.stop_polling
207
181
 
208
- expect(a_request(:get, endpoint)).to have_been_made.once
182
+ expect(stub).to have_been_requested.once
183
+ expect(new_stub).to have_been_requested.once
209
184
  end
210
185
  end
211
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.1
4
+ version: 5.1.1
5
5
  platform: java
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-13 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: rbtree-jruby
@@ -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
@@ -152,7 +154,7 @@ homepage: https://airbrake.io
152
154
  licenses:
153
155
  - MIT
154
156
  metadata: {}
155
- post_install_message:
157
+ post_install_message:
156
158
  rdoc_options: []
157
159
  require_paths:
158
160
  - lib
@@ -160,15 +162,15 @@ 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
- signing_key:
173
+ signing_key:
172
174
  specification_version: 4
173
175
  summary: Ruby notifier for https://airbrake.io
174
176
  test_files:
@@ -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