Module: TingYun::Instrumentation::TyphoeusTracing

Defined in:
lib/ting_yun/instrumentation/typhoeus.rb

Constant Summary collapse

EARLIEST_VERSION =
TingYun::Support::VersionNumber.new("0.5.3")

Class Method Summary collapse

Class Method Details

.is_supported_version?Boolean

Returns:

  • (Boolean)


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

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

.request_is_hydra_enabled?(request) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/ting_yun/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
73
74
# File 'lib/ting_yun/instrumentation/typhoeus.rb', line 63

def self.trace(request)
  if TingYun::Agent.tl_is_execution_traced? && !request_is_hydra_enabled?(request)
    wrapped_request = ::TingYun::Http::TyphoeusHTTPRequest.new(request)
    state = TingYun::Agent::TransactionState.tl_get
    t0 = Time.now.to_f
    segment = TingYun::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)
    request.on_complete do
      wrapped_response = ::TingYun::Http::TyphoeusHTTPResponse.new(request.response)
      TingYun::Agent::CrossAppTracing.finish_trace(TingYun::Agent::TransactionState.tl_get,t0, segment, wrapped_request, wrapped_response )
    end
  end
end