Class: Gruf::StackdriverTrace::ServerInterceptor
- Inherits:
-
Interceptors::ServerInterceptor
- Object
- Interceptors::ServerInterceptor
- Gruf::StackdriverTrace::ServerInterceptor
- Includes:
- Label
- Defined in:
- lib/gruf/stackdriver_trace/server_interceptor.rb
Instance Method Summary collapse
Methods included from Label
#get_host, #get_ua, #label_key, #request_context?, #set_basic_labels, #set_grpc_status_code, #set_label, #set_stack_trace, #status_code_to_label
Instance Method Details
#call ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gruf/stackdriver_trace/server_interceptor.rb', line 8 def call return yield if service.nil? trace = create_trace(request) begin Google::Cloud::Trace.set(trace) Google::Cloud::Trace.in_span("grpc-request-received") do |span| configure_span(span, request) result = Gruf::Interceptors::Timer.time do yield end set_grpc_status_code( span.labels, result.successful? ? ::GRPC::Core::StatusCodes::OK : result..code ) raise result. unless result.successful? result. end ensure Google::Cloud::Trace.set(nil) send_trace(trace) end end |