Method: Honeybadger::Plugins::Net::HTTP#request

Defined in:
lib/honeybadger/plugins/net_http.rb

#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