6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/istox/helpers/xray/grpc_client_xray_interceptor.rb', line 6
def call(request_context:)
no_segment = false
begin
no_segment = XRay.recorder.current_segment.blank?
rescue XRay::ContextMissingError
no_segment = true
end
XRay.recorder.begin_segment('grpc_request') if no_segment
XRay.recorder.begin_subsegment("grpc_request.#{request_context.method}")
request_context.metadata[:xray_trace_id] = XRay.recorder.current_segment.trace_id
request_context.metadata[:xray_parent_id] = XRay.recorder.current_segment.id
Thread.current[:tracer_id] = XRay.recorder.current_segment.trace_id
result = yield
XRay.recorder.end_subsegment
XRay.recorder.end_segment if no_segment
result
rescue StandardError => e
log.error e
raise e
end
|