Method: OneApm::Agent::CrossAppTracing.tl_trace_http_request

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

.tl_trace_http_request(request) ⇒ Object

Send the given request, adding metrics appropriate to the response when it comes back.

See the documentation for start_trace for an explanation of what request should look like.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/one_apm/agent/cross_app/cross_app_tracing.rb', line 36

def tl_trace_http_request(request)
  state = OneApm::TransactionState.tl_get
  return yield unless state.is_execution_traced?

  # It's important to set t0 outside the ensured block, otherwise there's
  # a race condition if we raise after begin but before t0's set.
  t0 = Time.now
  begin
    segment = start_trace(state, t0, request)
    response = yield
  ensure
    finish_trace(state, t0, segment, request, response)
  end

  return response
end