airbrake-ruby 5.0.2-java → 5.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7353bd2b22422a376f862a0af218a5fd67bd1a5074a759ee233b74bb5986c19
4
- data.tar.gz: 9f0debfc7e2eb97bd2dd0e263d1e40f81e3c8132d009dfc18a9cfcabf66fe31f
3
+ metadata.gz: b6e38e61b0caa09af3b9a0e0bf2deb678369bfe2c31e5923f9ec64d93f8456a7
4
+ data.tar.gz: 1936144cbf286ab6e43fbd8874d4093357ee4f7c2a7c43f0d7e507290e081d53
5
5
  SHA512:
6
- metadata.gz: 07ae0b29054ee4bf1a28d5aea1bc364e675290998dcad5a96ef9a218fa01173abc7577bba534bd10baf5786694aa86a3a2266ba42440947125c7a2dab4e6da5f
7
- data.tar.gz: dc8eacdeda076da7adffa1a469ed2ffe65e3d78a810cbf38b2e5a55ba584144f343a9cfa9a3c2b1cc036eabe79198045c4dc5e8239dd948c7292f3fba1a3e3fc
6
+ metadata.gz: 565a30fe46379d2da490d164e6d14462cba6bbb7817e8a008e676a396aa117abd6ac416cdc5b6c019204a2ab4b93c7d6cdd257c02c8ac4a335722463414f3933
7
+ data.tar.gz: 371aea04d52fef881b2b74c9781f0788b536711e1cfeecfd328ee6778f629e7f19eab793a557f42f6fa1603709ae7e20b1ec1abba527f26149acb3581a633f6c
@@ -42,6 +42,7 @@ module Airbrake
42
42
  # @return [Airbrake::RemoteSettings]
43
43
  def process_remote_configuration
44
44
  return unless @project_id
45
+ return if @config.environment == 'test'
45
46
 
46
47
  RemoteSettings.poll(@project_id, @config.remote_config_host) do |data|
47
48
  @poll_callback.call(data)
@@ -8,22 +8,11 @@ module Airbrake
8
8
  # config.error_notifications = data.error_notifications?
9
9
  # end
10
10
  #
11
- # When {#poll} is called, it will try to load remote settings from disk, so
12
- # that it doesn't wait on the result from the API call.
13
- #
14
- # When {#stop_polling} is called, the current config will be dumped to disk.
15
- #
16
11
  # @since 5.0.0
17
12
  # @api private
18
13
  class RemoteSettings
19
14
  include Airbrake::Loggable
20
15
 
21
- # @return [String] the path to the persistent config
22
- CONFIG_DUMP_PATH = File.join(
23
- File.expand_path(__dir__),
24
- '../../config/config.json',
25
- ).freeze
26
-
27
16
  # @return [Hash{Symbol=>String}] metadata to be attached to every GET
28
17
  # request
29
18
  QUERY_PARAMS = URI.encode_www_form(
@@ -54,18 +43,11 @@ module Airbrake
54
43
  @poll = nil
55
44
  end
56
45
 
57
- # Polls remote config of the given project in background. Loads local config
58
- # first (if exists).
46
+ # Polls remote config of the given project in background.
59
47
  #
60
48
  # @return [self]
61
49
  def poll
62
50
  @poll ||= Thread.new do
63
- begin
64
- load_config
65
- rescue StandardError => ex
66
- logger.error("#{LOG_LABEL} config loading failed: #{ex}")
67
- end
68
-
69
51
  @block.call(@data)
70
52
 
71
53
  loop do
@@ -77,17 +59,11 @@ module Airbrake
77
59
  self
78
60
  end
79
61
 
80
- # Stops the background poller thread. Dumps current config to disk.
62
+ # Stops the background poller thread.
81
63
  #
82
64
  # @return [void]
83
65
  def stop_polling
84
66
  @poll.kill if @poll
85
-
86
- begin
87
- dump_config
88
- rescue StandardError => ex
89
- logger.error("#{LOG_LABEL} config dumping failed: #{ex}")
90
- end
91
67
  end
92
68
 
93
69
  private
@@ -124,22 +100,5 @@ module Airbrake
124
100
  uri.query = QUERY_PARAMS
125
101
  uri
126
102
  end
127
-
128
- def load_config
129
- config_dir = File.dirname(CONFIG_DUMP_PATH)
130
- Dir.mkdir(config_dir) unless File.directory?(config_dir)
131
-
132
- return unless File.exist?(CONFIG_DUMP_PATH)
133
-
134
- config = File.read(CONFIG_DUMP_PATH)
135
- @data.merge!(JSON.parse(config))
136
- end
137
-
138
- def dump_config
139
- config_dir = File.dirname(CONFIG_DUMP_PATH)
140
- Dir.mkdir(config_dir) unless File.directory?(config_dir)
141
-
142
- File.write(CONFIG_DUMP_PATH, JSON.dump(@data.to_h))
143
- end
144
103
  end
145
104
  end
@@ -15,9 +15,9 @@ module Airbrake
15
15
  # @param [Airbrake::RemoteSettings::SettingsData] data
16
16
  # @return [void]
17
17
  def call(data)
18
- @config.logger.debug(
19
- "#{LOG_LABEL} applying remote settings: #{data.to_h}",
20
- )
18
+ @config.logger.debug do
19
+ "#{LOG_LABEL} applying remote settings: #{data.to_h}"
20
+ end
21
21
 
22
22
  @config.error_host = data.error_host if data.error_host
23
23
  @config.apm_host = data.apm_host if data.apm_host
@@ -3,7 +3,7 @@
3
3
  module Airbrake
4
4
  # @return [String] the library version
5
5
  # @api public
6
- AIRBRAKE_RUBY_VERSION = '5.0.2'.freeze
6
+ AIRBRAKE_RUBY_VERSION = '5.1.0'.freeze
7
7
 
8
8
  # @return [Hash{Symbol=>String}] the information about the notifier library
9
9
  # @since 5.0.0
@@ -53,9 +53,18 @@ RSpec.describe Airbrake::Config::Processor do
53
53
  end
54
54
  end
55
55
 
56
+ context "when the config sets environment to 'test'" do
57
+ let(:config) { Airbrake::Config.new(project_id: 123, environment: 'test') }
58
+
59
+ it "doesn't set remote settings" do
60
+ expect(Airbrake::RemoteSettings).not_to receive(:poll)
61
+ described_class.new(config).process_remote_configuration
62
+ end
63
+ end
64
+
56
65
  context "when the config defines a project_id" do
57
66
  let(:config) do
58
- Airbrake::Config.new(project_id: 123)
67
+ Airbrake::Config.new(project_id: 123, environment: 'not-test')
59
68
  end
60
69
 
61
70
  it "sets remote settings" do
@@ -44,7 +44,7 @@ RSpec.describe Airbrake::Filters::GitLastCheckoutFilter do
44
44
  it "attaches last checkouted email" do
45
45
  subject.call(notice)
46
46
  expect(notice[:context][:lastCheckout][:email]).to(
47
- match(/\A\w+[\w.-]*@\w+\.?\w+?\z/),
47
+ match(/\A\w+[\w.-]*@(\w+\.)*\w+\z/),
48
48
  )
49
49
  end
50
50
 
@@ -22,7 +22,9 @@ RSpec.describe Airbrake::RemoteSettings::Callback do
22
22
  end
23
23
 
24
24
  it "logs given data" do
25
- expect(logger).to receive(:debug).with(/applying remote settings/)
25
+ expect(logger).to receive(:debug) do |&block|
26
+ expect(block.call).to match(/applying remote settings/)
27
+ end
26
28
  described_class.new(config).call(data)
27
29
  end
28
30
 
@@ -22,42 +22,19 @@ 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, host) {}
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
@@ -68,21 +45,6 @@ RSpec.describe Airbrake::RemoteSettings do
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, host) {}
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
@@ -199,32 +161,4 @@ RSpec.describe Airbrake::RemoteSettings do
199
161
  end
200
162
  end
201
163
  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
-
208
- remote_settings = described_class.poll(project_id, host) {}
209
- sleep(0.2)
210
- remote_settings.stop_polling
211
-
212
- expect(stub).to have_been_requested.once
213
- end
214
-
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
- )
221
-
222
- remote_settings = described_class.poll(project_id, host) {}
223
- sleep(0.2)
224
- remote_settings.stop_polling
225
-
226
- expect(stub).to have_been_requested.once
227
- end
228
- end
229
- end
230
164
  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: 5.0.2
4
+ version: 5.1.0
5
5
  platform: java
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-18 00:00:00.000000000 Z
11
+ date: 2020-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree-jruby