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.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby.rb +1 -0
- data/lib/airbrake-ruby/backtrace.rb +6 -5
- data/lib/airbrake-ruby/config.rb +8 -36
- data/lib/airbrake-ruby/config/processor.rb +7 -17
- data/lib/airbrake-ruby/config/validator.rb +2 -0
- data/lib/airbrake-ruby/file_cache.rb +1 -1
- data/lib/airbrake-ruby/filter_chain.rb +1 -0
- data/lib/airbrake-ruby/filters/dependency_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +1 -2
- data/lib/airbrake-ruby/filters/git_repository_filter.rb +3 -0
- data/lib/airbrake-ruby/filters/git_revision_filter.rb +2 -0
- data/lib/airbrake-ruby/filters/keys_filter.rb +21 -13
- data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/sql_filter.rb +4 -4
- data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/thread_filter.rb +2 -0
- data/lib/airbrake-ruby/ignorable.rb +1 -0
- data/lib/airbrake-ruby/notice.rb +1 -8
- data/lib/airbrake-ruby/notice_notifier.rb +1 -0
- data/lib/airbrake-ruby/performance_breakdown.rb +1 -6
- data/lib/airbrake-ruby/performance_notifier.rb +1 -14
- data/lib/airbrake-ruby/promise.rb +1 -0
- data/lib/airbrake-ruby/query.rb +1 -6
- data/lib/airbrake-ruby/queue.rb +1 -8
- data/lib/airbrake-ruby/remote_settings.rb +20 -44
- data/lib/airbrake-ruby/remote_settings/callback.rb +44 -0
- data/lib/airbrake-ruby/remote_settings/settings_data.rb +14 -14
- data/lib/airbrake-ruby/request.rb +1 -8
- data/lib/airbrake-ruby/stat.rb +1 -12
- data/lib/airbrake-ruby/sync_sender.rb +2 -1
- data/lib/airbrake-ruby/tdigest.rb +2 -0
- data/lib/airbrake-ruby/thread_pool.rb +1 -0
- data/lib/airbrake-ruby/truncator.rb +8 -2
- data/lib/airbrake-ruby/version.rb +11 -1
- data/spec/backtrace_spec.rb +26 -26
- data/spec/code_hunk_spec.rb +2 -2
- data/spec/config/processor_spec.rb +13 -102
- data/spec/config_spec.rb +4 -29
- data/spec/filters/gem_root_filter_spec.rb +4 -4
- data/spec/filters/git_last_checkout_filter_spec.rb +1 -1
- data/spec/filters/keys_allowlist_spec.rb +1 -0
- data/spec/filters/keys_blocklist_spec.rb +10 -0
- data/spec/filters/root_directory_filter_spec.rb +4 -4
- data/spec/filters/sql_filter_spec.rb +2 -2
- data/spec/notice_notifier/options_spec.rb +2 -2
- data/spec/notice_notifier_spec.rb +2 -2
- data/spec/notice_spec.rb +1 -1
- data/spec/performance_breakdown_spec.rb +0 -12
- data/spec/performance_notifier_spec.rb +0 -25
- data/spec/query_spec.rb +1 -11
- data/spec/queue_spec.rb +1 -13
- data/spec/remote_settings/callback_spec.rb +143 -0
- data/spec/remote_settings/settings_data_spec.rb +34 -13
- data/spec/remote_settings_spec.rb +40 -88
- data/spec/request_spec.rb +1 -13
- data/spec/spec_helper.rb +4 -4
- data/spec/stat_spec.rb +0 -9
- 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
|
-
"
|
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(:
|
26
|
-
|
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(
|
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) {}
|
53
|
+
sleep(0.1)
|
54
|
+
remote_settings.stop_polling
|
55
|
+
|
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) {}
|
88
61
|
sleep(0.1)
|
89
62
|
remote_settings.stop_polling
|
90
63
|
|
91
|
-
|
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)
|
@@ -112,13 +88,13 @@ RSpec.describe Airbrake::RemoteSettings do
|
|
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(
|
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,58 @@ 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(
|
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
120
|
context "when API returns an XML response" do
|
145
|
-
|
146
|
-
stub_request(:get,
|
121
|
+
let!(:stub) do
|
122
|
+
stub_request(:get, Regexp.new(endpoint))
|
123
|
+
.to_return(status: 200, body: '<?xml ...')
|
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(
|
134
|
+
expect(stub).to have_been_requested.once
|
158
135
|
expect(settings.interval).to eq(600)
|
159
136
|
end
|
160
137
|
end
|
161
138
|
|
162
139
|
context "when a config route is specified in the returned data" do
|
163
|
-
let(:
|
140
|
+
let(:new_config_route) do
|
141
|
+
'213/config/111/config.json'
|
142
|
+
end
|
164
143
|
|
165
144
|
let(:body) do
|
166
|
-
{ 'config_route' =>
|
145
|
+
{ 'config_route' => new_config_route, 'poll_sec' => 0.1 }
|
167
146
|
end
|
168
147
|
|
169
|
-
|
170
|
-
stub_request(:get,
|
148
|
+
let!(:new_stub) do
|
149
|
+
stub_request(:get, Regexp.new(new_config_route))
|
150
|
+
.to_return(status: 200, body: body.to_json)
|
171
151
|
end
|
172
152
|
|
173
153
|
it "makes the next request to the specified config route" do
|
174
|
-
remote_settings = described_class.poll(project_id) {}
|
154
|
+
remote_settings = described_class.poll(project_id, host) {}
|
175
155
|
sleep(0.2)
|
176
156
|
|
177
157
|
remote_settings.stop_polling
|
178
158
|
|
179
|
-
expect(
|
180
|
-
expect(
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
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
|
193
|
-
|
194
|
-
expect(a_request(:get, endpoint)).to have_been_made.once
|
195
|
-
end
|
196
|
-
|
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
|
-
)
|
203
|
-
|
204
|
-
remote_settings = described_class.poll(project_id) {}
|
205
|
-
sleep(0.2)
|
206
|
-
remote_settings.stop_polling
|
207
|
-
|
208
|
-
expect(a_request(:get, endpoint)).to have_been_made.once
|
159
|
+
expect(stub).to have_been_requested.once
|
160
|
+
expect(new_stub).to have_been_requested.once
|
209
161
|
end
|
210
162
|
end
|
211
163
|
end
|
data/spec/request_spec.rb
CHANGED
@@ -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
|
data/spec/spec_helper.rb
CHANGED
@@ -33,7 +33,7 @@ class AirbrakeTestError < RuntimeError
|
|
33
33
|
|
34
34
|
def initialize(*)
|
35
35
|
super
|
36
|
-
# rubocop:disable
|
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
|
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
|
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
|
83
|
+
# rubocop:enable Layout/LineLength
|
84
84
|
end
|
85
85
|
|
86
86
|
def is_a?(*)
|
data/spec/stat_spec.rb
CHANGED
@@ -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.
|
4
|
+
version: 5.1.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: 2020-
|
11
|
+
date: 2020-10-20 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
|
@@ -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.
|
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:
|
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
|