Class: GrpcNewrelicInterceptor::ClientInterceptor
- Inherits:
-
GRPC::ClientInterceptor
- Object
- GRPC::ClientInterceptor
- GrpcNewrelicInterceptor::ClientInterceptor
- Defined in:
- lib/grpc_newrelic_interceptor/client_interceptor.rb
Instance Method Summary collapse
-
#request_response(request:, call:, method:, metadata:) ⇒ Object
Intercept a unary request response call.
Instance Method Details
#request_response(request:, call:, method:, metadata:) ⇒ Object
Intercept a unary request response call
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/grpc_newrelic_interceptor/client_interceptor.rb', line 14 def request_response(request:, call:, method:, metadata:) return yield if !newrelic_enabled? segment = NewRelic::Agent::Tracer.start_external_request_segment( library: "gRPC".freeze, uri: dummy_uri(method), procedure: get_method_name(method), ) begin response = nil # TODO(south37) Set metadta as reqeust headers # segment.add_request_headers something # RUBY-1244 Disable further tracing in request to avoid double # counting if connection wasn't started (which calls request again). NewRelic::Agent.disable_all_tracing do response = yield end # NOTE: Here, we can not get metadata of response. # TODO(south37) Improve ClientInterceptor to get metadata and set it as # response headers # segment.read_response_headers something response ensure segment.finish end end |