Class: Excon::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/one_apm/inst/http_clients/excon/connection.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.install_oneapm_instrumentationObject



26
27
28
29
# File 'lib/one_apm/inst/http_clients/excon/connection.rb', line 26

def self.install_oneapm_instrumentation
  alias request_without_oneapm_trace request
  alias request request_with_oneapm_trace
end

Instance Method Details

#oneapm_connection_paramsObject



5
6
7
# File 'lib/one_apm/inst/http_clients/excon/connection.rb', line 5

def oneapm_connection_params
  (@connection || @data)
end

#oneapm_resolved_request_params(request_params) ⇒ Object



9
10
11
12
13
# File 'lib/one_apm/inst/http_clients/excon/connection.rb', line 9

def oneapm_resolved_request_params(request_params)
  resolved = oneapm_connection_params.merge(request_params)
  resolved[:headers] = resolved[:headers].merge(request_params[:headers] || {})
  resolved
end

#request_with_oneapm_trace(params, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/one_apm/inst/http_clients/excon/connection.rb', line 15

def request_with_oneapm_trace(params, &block)
  orig_response = nil
  resolved_params = oneapm_resolved_request_params(params)
  wrapped_request = ::OneApm::Support::HTTPClients::ExconHTTPRequest.new(resolved_params)
  ::OneApm::Agent::CrossAppTracing.tl_trace_http_request(wrapped_request) do
    orig_response = request_without_oneapm_trace(resolved_params, &block)
    ::OneApm::Support::HTTPClients::ExconHTTPResponse.new(orig_response)
  end
  orig_response
end