Method: OneApm::Agent::CrossAppTracing.start_trace

Defined in:
lib/one_apm/agent/cross_app/cross_app_tracing.rb

.start_trace(state, t0, request) ⇒ Object

Set up the necessary state for cross-application tracing before the given request goes out.

The request object passed in must respond to the following methods:

  • type - Return a String describing the underlying library being used

    to make the request (e.g. 'Net::HTTP' or 'Typhoeus')
    
  • host - Return a String with the hostname or IP of the host being

    communicated with.
    
  • method - Return a String with the HTTP method name for this request

  • [](key) - Lookup an HTTP request header by name

  • []=(key, val) - Set an HTTP request header by name

  • uri - Full URI of the request

This method returns the transaction segment if it was sucessfully pushed.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/one_apm/agent/cross_app/cross_app_tracing.rb', line 68

def start_trace(state, t0, request)
  inject_request_headers(state, request) if cross_app_enabled?
  stack = state.traced_method_stack
  segment = stack.push_frame(state, :http_request, t0)

  return segment
rescue => err
  OneApm::Manager.logger.error "Uncaught exception while tracing HTTP request", err
  return nil
rescue Exception => e
  OneApm::Manager.logger.debug "Unexpected exception raised while tracing HTTP request", e

  raise e
end