Class: Gruf::Interceptors::Instrumentation::RequestLogging::Interceptor
- Inherits:
-
ServerInterceptor
- Object
- Base
- ServerInterceptor
- Gruf::Interceptors::Instrumentation::RequestLogging::Interceptor
- Defined in:
- lib/gruf/interceptors/instrumentation/request_logging/interceptor.rb
Overview
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#call ⇒ String
Log the request, sending it to the appropriate formatter.
Methods included from Errors::Helpers
Methods inherited from Base
Constructor Details
This class inherits a constructor from Gruf::Interceptors::Base
Instance Method Details
#call ⇒ String
Log the request, sending it to the appropriate formatter
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/gruf/interceptors/instrumentation/request_logging/interceptor.rb', line 45 def call result = Gruf::Interceptors::Timer.time do yield end if result.successful? type = .fetch(:success_log_level, :info).to_sym status_name = 'GRPC::Ok' else type = .fetch(:failure_log_level, :error).to_sym status_name = result. end payload = {} if !request.client_streamer? payload[:params] = sanitize(request..to_h) if .fetch(:log_parameters, false) payload[:message] = (request, result) payload[:status] = status(result., result.successful?) else payload[:params] = {} payload[:message] = '' payload[:status] = GRPC::Core::StatusCodes::OK end payload[:service] = request.service_key payload[:method] = request.method_key payload[:action] = request.method_key payload[:grpc_status] = status_name payload[:duration] = result.elapsed_rounded payload[:thread_id] = Thread.current.object_id payload[:time] = Time.now.to_s payload[:host] = Socket.gethostname ::Gruf.logger.send(type, formatter.format(payload)) raise result. unless result.successful? result. end |