Module: NewRelic::Agent::Instrumentation::TyphoeusTracing

Defined in:
lib/new_relic/agent/instrumentation/typhoeus.rb

Constant Summary collapse

EARLIEST_VERSION =
NewRelic::VersionNumber.new("0.5.3")

Class Method Summary collapse

Class Method Details

.is_supported_version?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/new_relic/agent/instrumentation/typhoeus.rb', line 55

def self.is_supported_version?
  NewRelic::VersionNumber.new(Typhoeus::VERSION) >= NewRelic::Agent::Instrumentation::TyphoeusTracing::EARLIEST_VERSION
end

.request_is_hydra_enabled?(request) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/new_relic/agent/instrumentation/typhoeus.rb', line 59

def self.request_is_hydra_enabled?(request)
  request.respond_to?(:hydra) && request.hydra
end

.trace(request) ⇒ Object



63
64
65
66
67
68
69
70
71
72
# File 'lib/new_relic/agent/instrumentation/typhoeus.rb', line 63

def self.trace(request)
  if NewRelic::Agent.is_execution_traced? && !request_is_hydra_enabled?(request)
    wrapped_request = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest.new(request)
    t0, segment = ::NewRelic::Agent::CrossAppTracing.start_trace(wrapped_request)
    request.on_complete do
      wrapped_response = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPResponse.new(request.response)
      ::NewRelic::Agent::CrossAppTracing.finish_trace(t0, segment, wrapped_request, wrapped_response)
    end if t0
  end
end