Module: GRPC::Core::CallWithTrace

Defined in:
lib/google/cloud/trace/patches/call_with_trace.rb

Overview

Stackdriver Trace instrumentation of GRPC by patching GRPC::Core::Call class. Add more RPC information into the trace span created by upstream patch from GRPC::ActiveCallWithTrace

Instance Method Summary collapse

Instance Method Details

#run_batch(*args) ⇒ Object

Override GRPC::Core::Call#run_batch method. Reuse the "gRPC request" span created in ActiveCallWithTrace patch to add more information from the request.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/google/cloud/trace/patches/call_with_trace.rb', line 68

def run_batch *args
  span = Google::Cloud::Trace.get
  # Make sure we're in a "gRPC request" span
  span = nil if !span.respond_to?(:name) || span.name != GRPC::ActiveCallWithTrace::SPAN_NAME

  if span && !args.empty?
    message = args[0]
    CallWithTrace.add_request_labels self, message, span.labels
  end

  response = super

  CallWithTrace.add_response_labels response, span.labels if span

  response
end