1818#include < async_simple/coro/Lazy.h>
1919
2020#include < any>
21+ #include < chrono>
2122#include < cstdint>
2223#include < functional>
2324#include < memory>
@@ -41,6 +42,8 @@ template <typename return_msg_type, typename rpc_protocol>
4142class context_base {
4243 protected:
4344 std::shared_ptr<context_info_t <rpc_protocol>> self_;
45+ std::chrono::steady_clock::time_point time_point_ =
46+ std::chrono::steady_clock::now ();
4447 typename rpc_protocol::req_header &get_req_head () { return self_->req_head_ ; }
4548
4649 bool check_status () {
@@ -80,10 +83,12 @@ class context_base {
8083 if (!check_status ())
8184 AS_UNLIKELY { return ; };
8285 ELOGI << " rpc error in function:" << self_->get_rpc_function_name ()
83- << " . error code:" << error_code.ec << " . message : " << error_msg;
86+ << " . error code:" << error_code.ec << " . message : " << error_msg
87+ << " conn id" << self_->conn_ ->get_connection_id ()
88+ << " request id:" << self_->get_request_id ();
8489 self_->conn_ ->template response_error <rpc_protocol>(
85- error_code, error_msg, self_->req_head_ ,
86- std::move (self_->complete_handler_ ));
90+ time_point_, self_->get_request_id (), error_code, error_msg ,
91+ self_-> req_head_ , std::move (self_->complete_handler_ ));
8792 }
8893 void response_error (coro_rpc::err_code error_code) {
8994 response_error (error_code, error_code.message ());
@@ -108,6 +113,7 @@ class context_base {
108113 std::visit (
109114 [&]<typename serialize_proto>(const serialize_proto &) {
110115 self_->conn_ ->template response_msg <rpc_protocol>(
116+ time_point_, self_->get_request_id (),
111117 serialize_proto::serialize (),
112118 std::move (self_->resp_attachment_ ), self_->req_head_ ,
113119 std::move (self_->complete_handler_ ));
@@ -122,6 +128,7 @@ class context_base {
122128 std::visit (
123129 [&]<typename serialize_proto>(const serialize_proto &) {
124130 self_->conn_ ->template response_msg <rpc_protocol>(
131+ time_point_, self_->get_request_id (),
125132 serialize_proto::serialize (ret),
126133 std::move (self_->resp_attachment_ ), self_->req_head_ ,
127134 std::move (self_->complete_handler_ ));
0 commit comments