module NewRelic::Agent::Instrumentation::TyphoeusTracing

Constants

EARLIEST_VERSION

Public Class Methods

is_supported_version?() click to toggle source
# File lib/new_relic/agent/instrumentation/typhoeus.rb, line 54
def self.is_supported_version?
  NewRelic::VersionNumber.new(Typhoeus::VERSION) >= NewRelic::Agent::Instrumentation::TyphoeusTracing::EARLIEST_VERSION
end
request_is_hydra_enabled?(request) click to toggle source
# File lib/new_relic/agent/instrumentation/typhoeus.rb, line 58
def self.request_is_hydra_enabled?(request)
  request.respond_to?(:hydra) && request.hydra
end
trace(request) click to toggle source
# File lib/new_relic/agent/instrumentation/typhoeus.rb, line 62
def self.trace(request)
  state = NewRelic::Agent::TransactionState.tl_get
  if state.is_execution_traced? && !request_is_hydra_enabled?(request)
    wrapped_request = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest.new(request)
    t0 = Time.now
    node = ::NewRelic::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)
    callback = Proc.new do
      wrapped_response = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPResponse.new(request.response)
      ::NewRelic::Agent::CrossAppTracing.finish_trace(state, t0, node, wrapped_request, wrapped_response)
    end
    request.on_complete.unshift(callback)
  end
rescue => e
  NewRelic::Agent.logger.error("Exception during trace setup for Typhoeus request", e)
end