airbrake-ruby 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8371a959c69ffddca0dd25b6e8096450ecea66e13ddd6f6ace583eb37976516
4
- data.tar.gz: f769f0604e3dd7118df53cb6de2e3115beed43a898e9eefb5828174c29f16f67
3
+ metadata.gz: f89d6e09b27f36f4d4450eeb9dd6fb9dff228ffe095769f8b9bcc24a02413842
4
+ data.tar.gz: a2b4daefe2139f002a42754b6df05c6c11dca9d80b0ecf440cd0620336a2d87e
5
5
  SHA512:
6
- metadata.gz: ef094ddf119abfe8fd552980dbbc05ce907ed7608c12f7012fbcde1ee7861a33da67a435c8ef6fc378ef2490274050b7ccde598ac2a1f0f1098cd587c36b1222
7
- data.tar.gz: 737a3900b60024d24303d10277d89ab782f60c58cadeb8e7fef3b7da17e983c8dd0033724e3640fe07d3428f1f86952f65ef378f81547213c2a8b11a9271eaa7
6
+ metadata.gz: 423f95e5781de19de642d880106b38feca43c98f9223956e4208b616929d6a63c56e1ca223d449115f232e60f0a84f9f0c52c140df708d2deaf20aa2dfca4a3e
7
+ data.tar.gz: e09266840dd038be725ad564d6db02696e5c6a0f188eae5206da30cbd2cf454eccbe56cbcf027b454821e6ef1bee29cb8fb2db7c7c61f81ffa6e0ecb1566c133
@@ -72,7 +72,7 @@ module Airbrake
72
72
  return unless File.exist?(head_path)
73
73
 
74
74
  last_line = nil
75
- IO.foreach(head_path) do |line|
75
+ File.foreach(head_path) do |line|
76
76
  last_line = line if checkout_line?(line)
77
77
  end
78
78
  last_line
@@ -1,7 +1,7 @@
1
1
  module Airbrake
2
2
  # RemoteSettings polls the remote config of the passed project at fixed
3
3
  # intervals. The fetched config is yielded as a callback parameter so that the
4
- # invoker can define read config values.
4
+ # invoker can define read config values. Supports proxies.
5
5
  #
6
6
  # @example Disable/enable error notifications based on the remote value
7
7
  # RemoteSettings.poll do |data|
@@ -43,6 +43,7 @@ module Airbrake
43
43
  @data = SettingsData.new(project_id, {})
44
44
  @host = host
45
45
  @block = block
46
+ @config = Airbrake::Config.instance
46
47
  @poll = nil
47
48
  end
48
49
 
@@ -72,11 +73,16 @@ module Airbrake
72
73
  private
73
74
 
74
75
  def fetch_config
76
+ uri = build_config_uri
77
+ https = build_https(uri)
78
+ req = Net::HTTP::Get.new(uri.request_uri)
75
79
  response = nil
80
+
76
81
  begin
77
- response = Net::HTTP.get_response(build_config_uri)
82
+ response = https.request(req)
78
83
  rescue StandardError => ex
79
- logger.error(ex)
84
+ reason = "#{LOG_LABEL} HTTP error: #{ex}"
85
+ logger.error(reason)
80
86
  return {}
81
87
  end
82
88
 
@@ -101,5 +107,22 @@ module Airbrake
101
107
  uri.query = QUERY_PARAMS
102
108
  uri
103
109
  end
110
+
111
+ def build_https(uri)
112
+ Net::HTTP.new(uri.host, uri.port, *proxy_params).tap do |https|
113
+ https.use_ssl = uri.is_a?(URI::HTTPS)
114
+ if @config.timeout
115
+ https.open_timeout = @config.timeout
116
+ https.read_timeout = @config.timeout
117
+ end
118
+ end
119
+ end
120
+
121
+ def proxy_params
122
+ return unless @config.proxy.key?(:host)
123
+
124
+ [@config.proxy[:host], @config.proxy[:port], @config.proxy[:user],
125
+ @config.proxy[:password]]
126
+ end
104
127
  end
105
128
  end
@@ -48,11 +48,11 @@ module Airbrake
48
48
  # false if the queue is full
49
49
  def <<(message)
50
50
  if backlog >= @queue_size
51
- logger.error(
51
+ logger.info do
52
52
  "#{LOG_LABEL} ThreadPool has reached its capacity of " \
53
53
  "#{@queue_size} and the following message will not be " \
54
- "processed: #{message.inspect}",
55
- )
54
+ "processed: #{message.inspect}"
55
+ end
56
56
  return false
57
57
  end
58
58
 
@@ -3,7 +3,7 @@
3
3
  module Airbrake
4
4
  # @return [String] the library version
5
5
  # @api public
6
- AIRBRAKE_RUBY_VERSION = '6.0.0'.freeze
6
+ AIRBRAKE_RUBY_VERSION = '6.0.1'.freeze
7
7
 
8
8
  # @return [Hash{Symbol=>String}] the information about the notifier library
9
9
  # @since v5.0.0
@@ -54,7 +54,7 @@ RSpec.describe Airbrake::Filters::GitRevisionFilter do
54
54
  end
55
55
  end
56
56
 
57
- context "and also when HEAD starts with 'ref: " do
57
+ context "and also when HEAD starts with 'ref: '" do
58
58
  before do
59
59
  allow(File).to(
60
60
  receive(:read).with('root/dir/.git/HEAD').and_return("ref: refs/foo\n"),
@@ -85,8 +85,12 @@ RSpec.describe Airbrake::RemoteSettings do
85
85
  end
86
86
 
87
87
  context "when an error is raised while making a HTTP request" do
88
+ let(:https) { instance_double(Net::HTTP) }
89
+
88
90
  before do
89
- allow(Net::HTTP).to receive(:get_response).and_raise(StandardError)
91
+ allow(Net::HTTP).to receive(:new).and_return(https)
92
+ allow(https).to receive(:use_ssl=).with(true)
93
+ allow(https).to receive(:request).and_raise(StandardError)
90
94
  end
91
95
 
92
96
  it "doesn't fetch remote settings" do
@@ -55,14 +55,13 @@ RSpec.describe Airbrake::ThreadPool do
55
55
  end
56
56
 
57
57
  it "logs discarded tasks" do
58
- allow(Airbrake::Loggable.instance).to receive(:error)
58
+ allow(Airbrake::Loggable.instance).to receive(:info)
59
59
 
60
60
  15.times { full_thread_pool << 1 }
61
61
  full_thread_pool.close
62
62
 
63
- expect(Airbrake::Loggable.instance).to have_received(:error).with(
64
- /reached its capacity/,
65
- ).exactly(15).times
63
+ expect(Airbrake::Loggable.instance)
64
+ .to have_received(:info).exactly(15).times
66
65
  end
67
66
  end
68
67
  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: 6.0.0
4
+ version: 6.0.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: 2021-09-20 00:00:00.000000000 Z
11
+ date: 2021-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree3