Module: HTTPInstrumentation::Instrumentation::HTTPClientHook

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

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.aliasedObject

Returns the value of attribute aliased.



21
22
23
# File 'lib/http_instrumentation/instrumentation/httpclient_hook.rb', line 21

def aliased
  @aliased
end

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, :do_get_block) if defined?(::HTTPClient)
end

Instance Method Details

#do_get_block(request, *args) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/http_instrumentation/instrumentation/httpclient_hook.rb', line 24

def do_get_block(request, *args)
  HTTPInstrumentation.instrument("httpclient") do |payload|
    response = if HTTPInstrumentation::Instrumentation::HTTPClientHook.aliased
      do_get_block_without_http_instrumentation(request, *args)
    else
      super
    end

    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