airbrake-ruby 5.1.0 → 5.1.1
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/config.rb +3 -1
- data/lib/airbrake-ruby/remote_settings.rb +7 -6
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/config_spec.rb +1 -1
- data/spec/remote_settings_spec.rb +26 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9438fdfe9308d48989fc04e1f9873c4cab46f7c22487ae1bd3d22e917d73f60
|
4
|
+
data.tar.gz: '08e6b8f6af0fd1ff980e642d9ce540c6c407844d34249bb921b9a15cd5f74ad7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6e892017febffa214ab8ea921fa8c09b1a27e6c2b0874d669e0dd64004b21fa27bd13ea65b750505e9c702c7248314e8d77ca6b57cb1ec4332c9157712d866d
|
7
|
+
data.tar.gz: c1ebc53b428eca54eb4c85e4fc094819c9c2972308b97069c6234502159d57c2b5977203fb8a60dd3865e7f8dca2f0430dd0f1500ef2df89f8f059a881433740
|
data/lib/airbrake-ruby/config.rb
CHANGED
@@ -126,6 +126,8 @@ module Airbrake
|
|
126
126
|
|
127
127
|
# @return [String] the host such as which should be used for fetching remote
|
128
128
|
# configuration options (example: "https://bucket-name.s3.amazonaws.com")
|
129
|
+
# @api private
|
130
|
+
# @since 5.0.0
|
129
131
|
attr_accessor :remote_config_host
|
130
132
|
|
131
133
|
class << self
|
@@ -151,7 +153,7 @@ module Airbrake
|
|
151
153
|
self.project_key = user_config[:project_key]
|
152
154
|
self.error_host = 'https://api.airbrake.io'
|
153
155
|
self.apm_host = 'https://api.airbrake.io'
|
154
|
-
self.remote_config_host = 'https://
|
156
|
+
self.remote_config_host = 'https://notifier-configs.airbrake.io'
|
155
157
|
|
156
158
|
self.ignore_environments = []
|
157
159
|
|
@@ -22,6 +22,9 @@ module Airbrake
|
|
22
22
|
language: "#{RUBY_ENGINE}/#{RUBY_VERSION}".freeze,
|
23
23
|
).freeze
|
24
24
|
|
25
|
+
# @return [String]
|
26
|
+
HTTP_OK = '200'.freeze
|
27
|
+
|
25
28
|
# Polls remote config of the given project.
|
26
29
|
#
|
27
30
|
# @param [Integer] project_id
|
@@ -71,22 +74,20 @@ module Airbrake
|
|
71
74
|
def fetch_config
|
72
75
|
response = nil
|
73
76
|
begin
|
74
|
-
response = Net::HTTP.
|
77
|
+
response = Net::HTTP.get_response(build_config_uri)
|
75
78
|
rescue StandardError => ex
|
76
79
|
logger.error(ex)
|
77
80
|
return {}
|
78
81
|
end
|
79
82
|
|
80
|
-
|
81
|
-
|
82
|
-
if response.start_with?('<?xml ')
|
83
|
-
logger.error(response)
|
83
|
+
unless response.code == HTTP_OK
|
84
|
+
logger.error(response.body)
|
84
85
|
return {}
|
85
86
|
end
|
86
87
|
|
87
88
|
json = nil
|
88
89
|
begin
|
89
|
-
json = JSON.parse(response)
|
90
|
+
json = JSON.parse(response.body)
|
90
91
|
rescue JSON::ParserError => ex
|
91
92
|
logger.error(ex)
|
92
93
|
return {}
|
data/spec/config_spec.rb
CHANGED
@@ -28,7 +28,7 @@ RSpec.describe Airbrake::Config do
|
|
28
28
|
its(:error_notifications) { is_expected.to eq(true) }
|
29
29
|
|
30
30
|
its(:remote_config_host) do
|
31
|
-
is_expected.to eq('https://
|
31
|
+
is_expected.to eq('https://notifier-configs.airbrake.io')
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "#new" do
|
@@ -83,7 +83,7 @@ RSpec.describe Airbrake::RemoteSettings do
|
|
83
83
|
|
84
84
|
context "when an error is raised while making a HTTP request" do
|
85
85
|
before do
|
86
|
-
allow(Net::HTTP).to receive(:
|
86
|
+
allow(Net::HTTP).to receive(:get_response).and_raise(StandardError)
|
87
87
|
end
|
88
88
|
|
89
89
|
it "doesn't fetch remote settings" do
|
@@ -117,10 +117,10 @@ RSpec.describe Airbrake::RemoteSettings do
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
-
context "when API returns
|
120
|
+
context "when API returns a non-200 response" do
|
121
121
|
let!(:stub) do
|
122
122
|
stub_request(:get, Regexp.new(endpoint))
|
123
|
-
.to_return(status:
|
123
|
+
.to_return(status: 201, body: body.to_json)
|
124
124
|
end
|
125
125
|
|
126
126
|
it "doesn't update settings data" do
|
@@ -134,6 +134,29 @@ RSpec.describe Airbrake::RemoteSettings do
|
|
134
134
|
expect(stub).to have_been_requested.once
|
135
135
|
expect(settings.interval).to eq(600)
|
136
136
|
end
|
137
|
+
|
138
|
+
it "logs error" do
|
139
|
+
expect(Airbrake::Loggable.instance).to receive(:error).with(body.to_json)
|
140
|
+
|
141
|
+
remote_settings = described_class.poll(project_id, host) {}
|
142
|
+
sleep(0.1)
|
143
|
+
remote_settings.stop_polling
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
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)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "doesn't log errors" do
|
154
|
+
expect(Airbrake::Loggable.instance).not_to receive(:error)
|
155
|
+
|
156
|
+
remote_settings = described_class.poll(project_id, host) {}
|
157
|
+
sleep(0.1)
|
158
|
+
remote_settings.stop_polling
|
159
|
+
end
|
137
160
|
end
|
138
161
|
|
139
162
|
context "when a config route is specified in the returned data" do
|
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.1.
|
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-
|
11
|
+
date: 2020-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbtree3
|