Module: HTTPInstrumentation::Instrumentation::HTTPClientHook

Defined in:
lib/http_instrumentation/instrumentation/httpclient_hook.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.installed?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/http_instrumentation/instrumentation/httpclient_hook.rb', line 17

def installed?
  !!(defined?(::HTTPClient) && ::HTTPClient.include?(self))
end

.instrument!Object



13
14
15
# File 'lib/http_instrumentation/instrumentation/httpclient_hook.rb', line 13

def instrument!
  Instrumentation.instrument!(::HTTPClient, self) if defined?(::HTTPClient)
end

Instance Method Details

#do_get_block(request) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/http_instrumentation/instrumentation/httpclient_hook.rb', line 22

def do_get_block(request, *)
  HTTPInstrumentation.instrument("httpclient") do |payload|
    response = super

    begin
      payload[:http_method] = request.header.request_method
      payload[:url] = request.header.request_uri
      payload[:status_code] = response.header.status_code
    rescue
    end

    response
  end
end