honeybadger 1.8.1 → 1.9.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/CHANGELOG.md +14 -0
  2. data/Gemfile.lock +61 -19
  3. data/Guardfile +4 -4
  4. data/MIT-LICENSE +1 -0
  5. data/README.md +2 -2
  6. data/Rakefile +4 -14
  7. data/features/rails.feature +1 -1
  8. data/gemfiles/rack.gemfile.lock +62 -27
  9. data/gemfiles/rails2.3.gemfile.lock +73 -36
  10. data/gemfiles/rails3.0.gemfile.lock +59 -26
  11. data/gemfiles/rails3.1.gemfile.lock +59 -26
  12. data/gemfiles/rails3.2.gemfile.lock +63 -30
  13. data/gemfiles/rails4.gemfile.lock +69 -36
  14. data/gemfiles/rake.gemfile.lock +62 -27
  15. data/gemfiles/sinatra.gemfile.lock +62 -27
  16. data/honeybadger.gemspec +31 -17
  17. data/lib/honeybadger.rb +2 -3
  18. data/lib/honeybadger/array.rb +53 -0
  19. data/lib/honeybadger/configuration.rb +19 -2
  20. data/lib/honeybadger/monitor.rb +16 -0
  21. data/lib/honeybadger/monitor/railtie.rb +52 -0
  22. data/lib/honeybadger/monitor/sender.rb +33 -0
  23. data/lib/honeybadger/monitor/worker.rb +71 -0
  24. data/lib/honeybadger/railtie.rb +10 -0
  25. data/lib/honeybadger/sender.rb +60 -41
  26. data/{test/unit/backtrace_test.rb → spec/honeybadger/backtrace_spec.rb} +69 -71
  27. data/{test/unit/capistrano_test.rb → spec/honeybadger/capistrano_spec.rb} +8 -9
  28. data/{test/unit/configuration_test.rb → spec/honeybadger/configuration_spec.rb} +85 -59
  29. data/spec/honeybadger/logger_spec.rb +65 -0
  30. data/spec/honeybadger/monitor/worker_spec.rb +189 -0
  31. data/{test/unit/notice_test.rb → spec/honeybadger/notice_spec.rb} +169 -185
  32. data/spec/honeybadger/notifier_spec.rb +252 -0
  33. data/spec/honeybadger/rack_spec.rb +84 -0
  34. data/{test/unit/rails/action_controller_catcher_test.rb → spec/honeybadger/rails/action_controller_spec.rb} +65 -57
  35. data/{test/unit/rails_test.rb → spec/honeybadger/rails_spec.rb} +8 -8
  36. data/spec/honeybadger/sender_spec.rb +249 -0
  37. data/spec/honeybadger_tasks_spec.rb +165 -0
  38. data/spec/spec_helper.rb +18 -0
  39. data/spec/support/array_including.rb +31 -0
  40. data/spec/support/backtraced_exception.rb +9 -0
  41. data/spec/support/collected_sender.rb +12 -0
  42. data/spec/support/defines_constants.rb +18 -0
  43. data/{test/test_helper.rb → spec/support/helpers.rb} +8 -61
  44. metadata +93 -45
  45. data/test/unit/honeybadger_tasks_test.rb +0 -167
  46. data/test/unit/logger_test.rb +0 -74
  47. data/test/unit/notifier_test.rb +0 -265
  48. data/test/unit/rack_test.rb +0 -88
  49. data/test/unit/sender_test.rb +0 -290
data/honeybadger.gemspec CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'honeybadger'
7
- s.version = '1.8.1'
8
- s.date = '2013-10-01'
7
+ s.version = '1.9.0.beta1'
8
+ s.date = '2013-10-08'
9
9
 
10
10
  s.summary = 'Error reports you can be happy about.'
11
11
  s.description = 'Make managing application errors a more pleasant experience.'
@@ -19,19 +19,22 @@ Gem::Specification.new do |s|
19
19
  s.rdoc_options = ['--charset=UTF-8', '--markup tomdoc']
20
20
  s.extra_rdoc_files = %w[README.md MIT-LICENSE]
21
21
 
22
+ s.add_dependency('faraday')
22
23
  s.add_dependency('json')
23
24
 
24
25
  s.add_development_dependency('cucumber', '~> 1.2.1')
25
- s.add_development_dependency('rspec', '~> 2.12.0')
26
+ s.add_development_dependency('rspec', '~> 2.14.0')
26
27
  s.add_development_dependency('fakeweb', '~> 1.3.0')
27
28
  s.add_development_dependency('sham_rack', '~> 1.3.0')
28
- s.add_development_dependency('bourne', '>= 1.0')
29
- s.add_development_dependency('shoulda', '~> 2.11.3')
30
29
  s.add_development_dependency('capistrano')
31
30
  s.add_development_dependency('rake')
32
31
  s.add_development_dependency('sinatra')
33
32
  s.add_development_dependency('aruba')
34
33
  s.add_development_dependency('appraisal')
34
+ s.add_development_dependency('guard')
35
+ s.add_development_dependency('guard-rspec')
36
+ s.add_development_dependency('fuubar')
37
+ s.add_development_dependency('growl')
35
38
 
36
39
  ## Leave this section as-is. It will be automatically generated from the
37
40
  ## contents of your Git repository via the gemspec task. DO NOT REMOVE
@@ -84,9 +87,14 @@ Gem::Specification.new do |s|
84
87
  generators/honeybadger/templates/initializer.rb
85
88
  honeybadger.gemspec
86
89
  lib/honeybadger.rb
90
+ lib/honeybadger/array.rb
87
91
  lib/honeybadger/backtrace.rb
88
92
  lib/honeybadger/capistrano.rb
89
93
  lib/honeybadger/configuration.rb
94
+ lib/honeybadger/monitor.rb
95
+ lib/honeybadger/monitor/railtie.rb
96
+ lib/honeybadger/monitor/sender.rb
97
+ lib/honeybadger/monitor/worker.rb
90
98
  lib/honeybadger/notice.rb
91
99
  lib/honeybadger/rack.rb
92
100
  lib/honeybadger/rails.rb
@@ -106,18 +114,24 @@ Gem::Specification.new do |s|
106
114
  resources/README.md
107
115
  resources/ca-bundle.crt
108
116
  script/integration_test.rb
109
- test/test_helper.rb
110
- test/unit/backtrace_test.rb
111
- test/unit/capistrano_test.rb
112
- test/unit/configuration_test.rb
113
- test/unit/honeybadger_tasks_test.rb
114
- test/unit/logger_test.rb
115
- test/unit/notice_test.rb
116
- test/unit/notifier_test.rb
117
- test/unit/rack_test.rb
118
- test/unit/rails/action_controller_catcher_test.rb
119
- test/unit/rails_test.rb
120
- test/unit/sender_test.rb
117
+ spec/honeybadger/backtrace_spec.rb
118
+ spec/honeybadger/capistrano_spec.rb
119
+ spec/honeybadger/configuration_spec.rb
120
+ spec/honeybadger/logger_spec.rb
121
+ spec/honeybadger/monitor/worker_spec.rb
122
+ spec/honeybadger/notice_spec.rb
123
+ spec/honeybadger/notifier_spec.rb
124
+ spec/honeybadger/rack_spec.rb
125
+ spec/honeybadger/rails/action_controller_spec.rb
126
+ spec/honeybadger/rails_spec.rb
127
+ spec/honeybadger/sender_spec.rb
128
+ spec/honeybadger_tasks_spec.rb
129
+ spec/spec_helper.rb
130
+ spec/support/array_including.rb
131
+ spec/support/backtraced_exception.rb
132
+ spec/support/collected_sender.rb
133
+ spec/support/defines_constants.rb
134
+ spec/support/helpers.rb
121
135
  ]
122
136
  # = MANIFEST =
123
137
 
data/lib/honeybadger.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'net/http'
2
- require 'net/https'
1
+ require 'faraday'
3
2
  require 'json'
4
3
  require 'digest'
5
4
  require 'logger'
@@ -14,7 +13,7 @@ require 'honeybadger/stats'
14
13
  require 'honeybadger/railtie' if defined?(Rails::Railtie)
15
14
 
16
15
  module Honeybadger
17
- VERSION = '1.8.1'
16
+ VERSION = '1.9.0.beta1'
18
17
  LOG_PREFIX = "** [Honeybadger] "
19
18
 
20
19
  HEADERS = {
@@ -0,0 +1,53 @@
1
+ # This code comes from batsd - I just decided to put this in a child
2
+ # class rather than re-opening Array.
3
+ class Honeybadger::Array < Array
4
+ # Calculates the sum of values in the array
5
+ def sum
6
+ inject( nil ) { |sum,x| sum ? sum+x : x };
7
+ end
8
+
9
+ # Calculates the arithmetic mean of values in the array
10
+ def mean
11
+ self.sum.to_f / self.length
12
+ end
13
+
14
+ # Calculates the median of values in the array
15
+ def median
16
+ self.sort[self.length/2]
17
+ end
18
+
19
+ # Calculates the value of the upper percentile of values
20
+ # in the array. If only a single value is provided in the array, that is
21
+ # returned
22
+ def percentile(threshold)
23
+ if (count > 1)
24
+ self.sort!
25
+ # strip off the top 100-threshold
26
+ threshold_index = (((100 - threshold).to_f / 100) * count).round
27
+ self[0..-threshold_index].last
28
+ else
29
+ self.first
30
+ end
31
+ end
32
+
33
+ # Calculates the mean squared error of values in the array
34
+ def mean_squared
35
+ m = mean
36
+ self.class.new(map{|v| (v-m)**2}).sum
37
+ end
38
+
39
+ # Calculates the standard deviatiation of values in the array
40
+ def standard_dev
41
+ (mean_squared/(count-1))**0.5
42
+ end
43
+
44
+ # Allow [1,2,3].percentile_90, [1,2,3].percentile(75), etc.
45
+ def method_missing(method, *args, &block)
46
+ if method.to_s =~ /^percentile_(.+)$/
47
+ percentile($1.to_i)
48
+ else
49
+ super
50
+ end
51
+ end
52
+
53
+ end
@@ -1,3 +1,5 @@
1
+ require 'socket'
2
+
1
3
  module Honeybadger
2
4
  class Configuration
3
5
  OPTIONS = [:api_key, :backtrace_filters, :development_environments, :environment_name,
@@ -107,6 +109,12 @@ module Honeybadger
107
109
  # Override the hostname of the local server (optional)
108
110
  attr_accessor :hostname
109
111
 
112
+ # Send metrics?
113
+ attr_accessor :metrics
114
+
115
+ # Which features the API says we have
116
+ attr_accessor :features
117
+
110
118
  DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze
111
119
 
112
120
  DEFAULT_BACKTRACE_FILTERS = [
@@ -161,7 +169,10 @@ module Honeybadger
161
169
  @source_extract_radius = 2
162
170
  @send_request_session = true
163
171
  @debug = false
164
- @hostname = nil
172
+ @hostname = Socket.gethostname
173
+ @metrics = true
174
+ @features = { 'notices' => true }
175
+ @limit = nil
165
176
  end
166
177
 
167
178
  # Public: Takes a block and adds it to the list of backtrace filters. When
@@ -248,7 +259,13 @@ module Honeybadger
248
259
  #
249
260
  # Returns false if in a development environment, true otherwise.
250
261
  def public?
251
- !development_environments.include?(environment_name)
262
+ !development_environments.include?(environment_name) && features['notices']
263
+ end
264
+
265
+ # Public: Determines whether to send metrics
266
+ #
267
+ def metrics?
268
+ public? && @metrics
252
269
  end
253
270
 
254
271
  # Public: Configure async delivery
@@ -0,0 +1,16 @@
1
+ require "honeybadger/array"
2
+ require "honeybadger/monitor/sender"
3
+ require "honeybadger/monitor/worker"
4
+ require "honeybadger/monitor/railtie" if defined?(Rails)
5
+
6
+ module Honeybadger
7
+ module Monitor
8
+ class << self
9
+
10
+ def worker
11
+ Worker.instance
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,52 @@
1
+ module Honeybadger
2
+ module Monitor
3
+ class Railtie < ::Rails::Railtie
4
+
5
+ config.after_initialize do
6
+ if Honeybadger.configuration.metrics?
7
+
8
+ ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
9
+ event = ActiveSupport::Notifications::Event.new(*args)
10
+ status = event.payload[:exception] ? 500 : event.payload[:status]
11
+ Monitor.worker.timing("app.request.#{status}", event.duration)
12
+
13
+ controller = event.payload[:controller]
14
+ action = event.payload[:action]
15
+ if controller && action
16
+ Monitor.worker.timing("app.controller.#{controller}.#{action}.total", event.duration)
17
+ Monitor.worker.timing("app.controller.#{controller}.#{action}.view", event.payload[:view_runtime]) if event.payload[:view_runtime]
18
+ Monitor.worker.timing("app.controller.#{controller}.#{action}.db", event.payload[:db_runtime]) if event.payload[:db_runtime]
19
+ end
20
+ end
21
+
22
+ ActiveSupport::Notifications.subscribe(/render_(partial|template)\.action_view\Z/) do |*args|
23
+ event = ActiveSupport::Notifications::Event.new(*args)
24
+ if !event.name.start_with?('!')
25
+ metric = event.name.split('.').first
26
+ file = event.payload[:identifier].gsub(::Rails.root.to_s + File::SEPARATOR,'').gsub('.', '_')
27
+ Monitor.worker.timing("app.view.#{metric}.#{file}", event.duration)
28
+ end
29
+ end
30
+
31
+ ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
32
+ event = ActiveSupport::Notifications::Event.new(*args)
33
+ if event.name != 'SCHEMA' && !event.name == 'CACHE'
34
+ metric = event.payload[:sql].strip.split(' ', 2).first.downcase
35
+ Monitor.worker.timing("app.active_record.#{metric}", event.duration)
36
+ end
37
+ end
38
+
39
+ ActiveSupport::Notifications.subscribe(/(deliver|receive).action_mailer\Z/) do |*args|
40
+ event = ActiveSupport::Notifications::Event.new(*args)
41
+ if !event.name.start_with?('!')
42
+ metric = event.name.split('.').first
43
+ Monitor.worker.timing("app.mail.#{metric}", event.duration)
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,33 @@
1
+ module Honeybadger
2
+ module Monitor
3
+ class Sender < Honeybadger::Sender
4
+ def send_metrics(data)
5
+ return unless Honeybadger.configuration.metrics?
6
+
7
+ if !Honeybadger.configuration.features['metrics']
8
+ log(:error, "Can't send metrics -- the gem has been deactivated by the remote service. Try restarting your app or contacting support@honeybadger.io.")
9
+ Honeybadger.configuration.metrics = false
10
+ return nil
11
+ end
12
+
13
+ response = client.post do |p|
14
+ p.url "/v1/metrics"
15
+ p.body = data.to_json
16
+ end
17
+
18
+ if response.success?
19
+ true
20
+ else
21
+ Honeybadger.configuration.features['metrics'] = false if response.status == 403
22
+ log(:error, "Metrics Failure", response, data)
23
+ false
24
+ end
25
+
26
+ rescue => e
27
+ log(:error, "[Honeybadger::Monitor::Sender#send_metrics] Error: #{e.class} - #{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}")
28
+ true
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,71 @@
1
+ require "singleton"
2
+
3
+ module Honeybadger
4
+ module Monitor
5
+ class Worker
6
+ include Singleton
7
+
8
+ def initialize
9
+ init_metrics
10
+ @delay = 60
11
+ @per_request = 100
12
+ @sender = Monitor::Sender.new(Honeybadger.configuration)
13
+ @thread = Thread.new do
14
+ while true do
15
+ send_metrics
16
+ sleep @delay
17
+ end
18
+ end
19
+ end
20
+
21
+ def timing(name, value)
22
+ add_metric(name, value, :timing)
23
+ end
24
+
25
+ def increment(name, value)
26
+ add_metric(name, value, :counter)
27
+ end
28
+
29
+ protected
30
+
31
+ def init_metrics
32
+ @metrics = { :timing => {}, :counter => {} }
33
+ end
34
+
35
+ def send_metrics
36
+ metrics = @metrics.dup
37
+ return unless metrics[:timing].any? || metrics[:counter].any?
38
+ init_metrics
39
+ [].tap do |m|
40
+ metrics[:counter].each do |metric, values|
41
+ m << "#{metric} #{values.sum}"
42
+ end
43
+ metrics[:timing].each do |metric, values|
44
+ m << "#{metric}:mean #{values.mean}"
45
+ m << "#{metric}:median #{values.median}"
46
+ m << "#{metric}:percentile_90 #{values.percentile(90)}"
47
+ m << "#{metric}:min #{values.min}"
48
+ m << "#{metric}:max #{values.max}"
49
+ m << "#{metric}:stddev #{values.standard_dev}" if values.count > 1
50
+ m << "#{metric} #{values.count}"
51
+ end
52
+ end.each_slice(@per_request) do |mm|
53
+ begin
54
+ @sender.send_metrics({ :metrics => mm, :environment => Honeybadger.configuration.environment_name, :hostname => Honeybadger.configuration.hostname })
55
+ rescue Exception => e
56
+ log(:error, "[Honeybadger::Monitor::Worker#send_metrics] Failed to send #{mm.count} metrics: #{e.class} - #{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}")
57
+ end
58
+ end
59
+ end
60
+
61
+ def add_metric(name, value, kind)
62
+ (@metrics[kind][name] ||= Honeybadger::Array.new) << value
63
+ end
64
+
65
+ def log(level, message)
66
+ Honeybadger.write_verbose_log(message, level)
67
+ end
68
+
69
+ end
70
+ end
71
+ end
@@ -1,4 +1,5 @@
1
1
  require 'honeybadger'
2
+ require 'honeybadger/monitor'
2
3
  require 'rails'
3
4
 
4
5
  module Honeybadger
@@ -40,6 +41,15 @@ module Honeybadger
40
41
  require 'honeybadger/rails/middleware/exceptions_catcher'
41
42
  ::ActionDispatch::ShowExceptions.send(:include,Honeybadger::Rails::Middleware::ExceptionsCatcher)
42
43
  end
44
+
45
+ if Honeybadger.configuration.public?
46
+ if result = Honeybadger.sender.ping({ :version => Honeybadger::VERSION, :framework => Honeybadger.configuration.framework, :environment => Honeybadger.configuration.environment_name, :hostname => Honeybadger.configuration.hostname })
47
+ Honeybadger.configure(true) do |config|
48
+ config.features = result['features'] if result['features']
49
+ config.limit = result['limit'] if result['limit']
50
+ end
51
+ end
52
+ end
43
53
  end
44
54
  end
45
55
  end
@@ -5,9 +5,6 @@ module Honeybadger
5
5
  Errno::EINVAL,
6
6
  Errno::ECONNRESET,
7
7
  EOFError,
8
- Net::HTTPBadResponse,
9
- Net::HTTPHeaderSyntaxError,
10
- Net::ProtocolError,
11
8
  Errno::ECONNREFUSED].freeze
12
9
 
13
10
  def initialize(options = {})
@@ -34,38 +31,57 @@ module Honeybadger
34
31
  #
35
32
  # Returns error id from successful response
36
33
  def send_to_honeybadger(notice)
37
- if api_key.nil?
38
- log(:error, "API key not found.")
34
+ if !Honeybadger.configuration.features['notices']
35
+ log(:error, "Can't send error report -- the gem has been deactivated by the remote service. Try restarting your app or contacting support@honeybadger.io.")
39
36
  return nil
40
37
  end
41
38
 
42
- data = notice.is_a?(String) ? notice : notice.to_json
43
-
44
- http = setup_http_connection
45
- headers = HEADERS
39
+ return nil unless api_key_ok?
46
40
 
47
- headers.merge!({ 'X-API-Key' => api_key})
41
+ data = notice.is_a?(String) ? notice : notice.to_json
48
42
 
49
43
  response = begin
50
- http.post(url.path, data, headers)
44
+ client.post do |p|
45
+ p.url NOTICES_URI
46
+ p.body = data
47
+ end
51
48
  rescue *HTTP_ERRORS => e
52
49
  log(:error, "Unable to contact the Honeybadger server. HTTP Error=#{e}")
53
50
  nil
54
51
  end
55
52
 
56
- case response
57
- when Net::HTTPSuccess then
53
+ if response.success?
58
54
  log(Honeybadger.configuration.debug ? :info : :debug, "Success: #{response.class}", response, data)
59
- JSON.parse(response.body)['id']
55
+ JSON.parse(response.body).fetch('id')
60
56
  else
61
57
  log(:error, "Failure: #{response.class}", response, data)
62
- nil
63
58
  end
59
+
64
60
  rescue => e
65
61
  log(:error, "[Honeybadger::Sender#send_to_honeybadger] Error: #{e.class} - #{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}")
66
62
  nil
67
63
  end
68
64
 
65
+ def ping(data = {})
66
+ return nil unless api_key_ok?
67
+
68
+ response = client.post do |p|
69
+ p.url "/v1/ping"
70
+ p.body = data.to_json
71
+ end
72
+
73
+ if response.success?
74
+ JSON.parse(response.body)
75
+ else
76
+ log(:error, "Ping Failure", response, data)
77
+ nil
78
+ end
79
+
80
+ rescue => e
81
+ log(:error, "[Honeybadger::Sender#ping] Error: #{e.class} - #{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}")
82
+ nil
83
+ end
84
+
69
85
  attr_reader :api_key,
70
86
  :proxy_host,
71
87
  :proxy_port,
@@ -84,8 +100,34 @@ module Honeybadger
84
100
 
85
101
  private
86
102
 
87
- def url
88
- URI.parse("#{protocol}://#{host}:#{port}").merge(NOTICES_URI)
103
+ def api_key_ok?
104
+ if api_key.nil? || api_key == ''
105
+ log(:error, "API key not found.")
106
+ return nil
107
+ end
108
+ true
109
+ end
110
+
111
+ def client
112
+ request_options = { :timeout => http_read_timeout, :open_timeout => http_open_timeout }
113
+ request_options.merge!({ :proxy => { :uri => "#{protocol}://#{proxy_host}:#{proxy_port || port}", :user => proxy_user, :password => proxy_pass } }) if proxy_host
114
+
115
+ @client ||= Faraday.new(:request => request_options) do |conn|
116
+ conn.adapter Faraday.default_adapter
117
+ conn.url_prefix = "#{protocol}://#{host}:#{port}"
118
+ conn.headers['User-agent'] = "HB-Ruby #{Honeybadger::VERSION}; #{RUBY_VERSION}; #{RUBY_PLATFORM}"
119
+ conn.headers['X-API-Key'] = api_key.to_s
120
+ conn.headers['Content-Type'] = 'application/json'
121
+ conn.headers['Accept'] = 'text/json, application/json'
122
+
123
+ if secure?
124
+ conn.ssl[:verify_mode] = OpenSSL::SSL::VERIFY_PEER
125
+ conn.ssl[:ca_file] = Honeybadger.configuration.ca_bundle_path
126
+ end
127
+ end
128
+ rescue => e
129
+ log(:error, "[Honeybadger::Sender#client] Failure initializing the HTTP connection.\nError: #{e.class} - #{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}")
130
+ raise e
89
131
  end
90
132
 
91
133
  def log(level, message, response = nil, data = nil)
@@ -94,31 +136,8 @@ module Honeybadger
94
136
 
95
137
  # Log debug information:
96
138
  Honeybadger.report_environment_info
97
- Honeybadger.report_response_body(response.body) if response && response.respond_to?(:body)
139
+ Honeybadger.report_response_body(response.body) if response && response.body =~ /\S/
98
140
  Honeybadger.write_verbose_log("Notice: #{data}", :debug) if data && Honeybadger.configuration.debug
99
141
  end
100
-
101
- def setup_http_connection
102
- http =
103
- Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_pass).
104
- new(url.host, url.port)
105
-
106
- http.read_timeout = http_read_timeout
107
- http.open_timeout = http_open_timeout
108
-
109
- if secure?
110
- http.use_ssl = true
111
-
112
- http.ca_file = Honeybadger.configuration.ca_bundle_path
113
- http.verify_mode = OpenSSL::SSL::VERIFY_PEER
114
- else
115
- http.use_ssl = false
116
- end
117
-
118
- http
119
- rescue => e
120
- log(:error, "[Honeybadger::Sender#setup_http_connection] Failure initializing the HTTP connection.\nError: #{e.class} - #{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}")
121
- raise e
122
- end
123
142
  end
124
143
  end