module Mmtrix::Agent::Instrumentation::TyphoeusTracing

Constants

EARLIEST_VERSION

Public Class Methods

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