lib/grpc_opencensus_interceptor/server_interceptor.rb
def request_response(request:, call:, method:)
      context_bin = call.metadata[Util::OPENCENSUS_TRACE_BIN_KEY]
      if context_bin
        context = deserialize(context_bin)
      else
        context = nil
      end

      OpenCensus::Trace.start_request_trace(
        trace_context:          context,
        same_process_as_parent: false) do |span_context|
        begin
          OpenCensus::Trace.in_span get_name(method) do |span|
            modify_span(span, request, call, method)

            start_request(span, call, method)
            begin
              grpc_ex = GRPC::Ok.new
              yield
            rescue StandardError => e
              grpc_ex = Util.to_grpc_ex(e)
              raise e
            ensure
              finish_request(span, grpc_ex)
            end
          end
        ensure
          @exporter.export span_context.build_contained_spans
        end
      end
    end
##
# Intercept a unary request response call.
#
# @param [Object] request
# @param [GRPC::ActiveCall::SingleReqView] call
# @param [Method] method
#
Intercept a unary request response call.
Intercept a unary request response call .
def request_response(request:, call:, method:)
      context_bin = call.metadata[Util::OPENCENSUS_TRACE_BIN_KEY]
      if context_bin
        context = deserialize(context_bin)
      else
        context = nil
      end
      OpenCensus::Trace.start_request_trace(
        trace_context:          context,
        same_process_as_parent: false) do |span_context|
        begin
          OpenCensus::Trace.in_span get_name(method) do |span|
            modify_span(span, request, call, method)
            start_request(span, call, method)
            begin
              grpc_ex = GRPC::Ok.new
              yield
            rescue StandardError => e
              grpc_ex = Util.to_grpc_ex(e)
              raise e
            ensure
              finish_request(span, grpc_ex)
            end
          end
        ensure
          @exporter.export span_context.build_contained_spans
        end
      end
    end
def request_response ( request : , call : , method : ) context_bin = call . metadata [ Util :: OPENCENSUS_TRACE_BIN_KEY ] if context_bin context = deserialize ( context_bin ) else context = nil end OpenCensus :: Trace . start_request_trace ( trace_context : context , same_process_as_parent : false ) do | span_context | begin OpenCensus :: Trace . in_span get_name ( method ) do | span | modify_span ( span , request , call , method ) start_request ( span , call , method ) begin grpc_ex = GRPC :: Ok . new yield rescue StandardError => e grpc_ex = Util . to_grpc_ex ( e ) raise e ensure finish_request ( span , grpc_ex ) end end ensure @exporter . export span_context . build_contained_spans end end end
Intercept a unary request response call.
Intercept a unary request response call .
request
call
method
None