Module: Chronos::Integrations::NetHttp::InstrumentedRequest

Defined in:
lib/chronos/integrations/net_http.rb

Overview

Request wrapper prepended only to an explicitly selected HTTP object.

Examples:

connection.request(Net::HTTP::Get.new("/health"))

Instance Method Summary collapse

Instance Method Details

#request(request, body = nil, &block) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/chronos/integrations/net_http.rb', line 85

def request(request, body = nil, &block)
  options = instance_variable_get(NetHttp::OPTIONS_KEY)
  started_at = options[:clock].call
  inject_trace_headers(request, options) if options[:trace_headers]
  response = super(request, body, &block)
  record_external_http(options, request, started_at, response, nil)
  response
rescue StandardError => error
  record_external_http(options, request, started_at, nil, error) if options && started_at
  raise
end