Module: Honeybadger::Plugins::Net::HTTP Private
- Defined in:
- lib/honeybadger/plugins/net_http.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- @@hb_config =
This classvariable is part of a private API. You should avoid using this classvariable if possible, as it may be removed or be changed in the future.
::Honeybadger.config
Class Method Summary collapse
- .set_hb_config(config) ⇒ Object private
Instance Method Summary collapse
- #build_uri(request_data) ⇒ Object private
- #hb? ⇒ Boolean private
- #parsed_uri_data(request_data) ⇒ Object private
- #request(request_data, body = nil, &block) ⇒ Object private
Class Method Details
.set_hb_config(config) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/honeybadger/plugins/net_http.rb', line 12 def self.set_hb_config(config) @@hb_config = config end |
Instance Method Details
#build_uri(request_data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 53 |
# File 'lib/honeybadger/plugins/net_http.rb', line 50 def build_uri(request_data) hostname = (address[/#{Resolv::IPv6::Regex}/]) ? "[#{address}]" : address URI.parse("#{use_ssl? ? 'https' : 'http'}://#{hostname}#{request_data.path}") end |
#hb? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 |
# File 'lib/honeybadger/plugins/net_http.rb', line 38 def hb? address.to_s[/#{@@hb_config[:'connection.host'].to_s}/] end |
#parsed_uri_data(request_data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 46 47 48 |
# File 'lib/honeybadger/plugins/net_http.rb', line 42 def parsed_uri_data(request_data) uri = request_data.uri || build_uri(request_data) {}.tap do |uri_data| uri_data[:host] = uri.host uri_data[:url] = uri.to_s if @@hb_config[:'net_http.insights.full_url'] end end |
#request(request_data, body = nil, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/honeybadger/plugins/net_http.rb', line 16 def request(request_data, body = nil, &block) return super unless started? return super if hb? Honeybadger.instrumentation.monotonic_timer { super }.tap do |duration, response_data| context = { duration: duration, method: request_data.method, status: response_data.code.to_i }.merge(parsed_uri_data(request_data)) if @@hb_config.load_plugin_insights_events?(:net_http) Honeybadger.event('request.net_http', context) end if @@hb_config.load_plugin_insights_metrics?(:net_http) context.delete(:url) Honeybadger.gauge('duration.request', context.merge(metric_source: 'net_http')) end end[1] # return the response data only end |