Class: Griffin::Interceptors::Client::LoggingInterceptor
- Inherits:
-
GRPC::ClientInterceptor
- Object
- GRPC::ClientInterceptor
- Griffin::Interceptors::Client::LoggingInterceptor
- Defined in:
- lib/griffin/interceptors/client/logging_interceptor.rb
Instance Method Summary collapse
- #request_response(call: nil) ⇒ Object (also: #server_streamer, #client_streamer, #bidi_streamer)
Instance Method Details
#request_response(call: nil) ⇒ Object Also known as: server_streamer, client_streamer, bidi_streamer
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/griffin/interceptors/client/logging_interceptor.rb', line 7 def request_response(call: nil, **) now = Time.now log = build_log(call, now) resp = begin yield rescue => e if e.is_a?(GRPC::BadStatus) log['grpc.code'] = e.code else log['grpc.code'] = '2' # UNKNOWN end log['grpc.duration'] = (Time.now - now).to_s GRPC.logger.info(log) raise e end log['grpc.duration'] = (Time.now - now).to_s GRPC.logger.info(log) resp end |