lib/railway_ipc/rpc/client/client.rb in railway-ipc-1.1.0 vs lib/railway_ipc/rpc/client/client.rb in railway-ipc-2.0.0

- old
+ new

@@ -37,22 +37,30 @@ def registered_handlers RailwayIpc::RPC::ClientResponseHandlers.instance.registered end # rubocop:disable Metrics/AbcSize + # rubocop:disable Metrics/MethodLength def process_payload(response) decoded_payload = decode_payload(response) case decoded_payload.type when *registered_handlers @message = get_message_class(decoded_payload).decode(decoded_payload.message) - RailwayIpc.logger.info(message, 'Handling response') + RailwayIpc.logger.info( + 'Handling response', + feature: 'railway_ipc_consumer', + exchange: self.class.exchange_name, + queue: self.class.queue_name, + protobuf: { type: message.class, data: message } + ) RailwayIpc::Response.new(message, success: true) else @message = LearnIpc::ErrorMessage.decode(decoded_payload.message) raise RailwayIpc::UnhandledMessageError.new("#{self.class} does not know how to handle #{decoded_payload.type}") end end + # rubocop:enable Metrics/MethodLength # rubocop:enable Metrics/AbcSize def setup_rabbit_connection rabbit_connection .connect @@ -76,14 +84,16 @@ end private def log_exception(exception, payload) - RailwayIpc.logger.log_exception( - feature: 'railway_consumer', + RailwayIpc.logger.error( + exception.message, + feature: 'railway_ipc_consumer', + exchange: self.class.exchange_name, + queue: self.class.queue_name, error: exception.class, - error_message: exception.message, payload: decode_for_error(exception, payload) ) end def get_message_class(decoded_payload) @@ -97,10 +107,15 @@ def attach_reply_queue_to_message request_message.reply_to = rabbit_connection.queue.name end def publish_message - RailwayIpc.logger.info(request_message, 'Sending request') + RailwayIpc.logger.info( + 'Sending request', + feature: 'railway_ipc_publisher', + exchange: self.class.exchange_name, + protobuf: { type: request_message.class, data: request_message } + ) rabbit_connection.publish(RailwayIpc::Rabbitmq::Payload.encode(request_message), routing_key: '') end def decode_for_error(exception, payload) return exception.message unless payload