68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/one_apm/agent/cross_app/cross_app_tracing_message.rb', line 68
def finish_trace(state, t0, segment, request, metrics)
unless t0
OneApm::Manager.logger.error("RPC request trace finished without start time. This is probably an agent bug.")
return
end
t1 = Time.now
duration = t1.to_f - t0.to_f
begin
if request
scoped_metric, *other_metrics = metrics
OneApm::Manager.agent.stats_engine.record_scoped_and_unscoped_metrics(state, scoped_metric, nil, duration)
if segment
segment.name = scoped_metric
end
end
ensure
if segment
stack = state.traced_method_stack
stack.pop_frame(state, segment, scoped_metric, t1)
end
end
rescue OneApm::Agent::CrossAppTracingMessage::Error => err
OneApm::Manager.logger.debug "while cross app tracing", err
rescue => err
OneApm::Manager.logger.error "Uncaught exception while finishing an RPC request trace", err
end
|