Unverified Commit 11e9156e authored by Ge Jun's avatar Ge Jun Committed by GitHub

Merge pull request #538 from zyearn/add_server_processed_time

add server processed time in controller
parents 8588ff83 876c8d9e
......@@ -172,8 +172,15 @@ public:
// True if a backup request was sent during the RPC.
bool has_backup_request() const { return has_flag(FLAGS_BACKUP_REQUEST); }
// Get latency of the RPC call.
int64_t latency_us() const { return _end_time_us - _begin_time_us; }
// This function has different meanings in client and server side.
// In client side it gets latency of the RPC call. While in server side,
// it gets queue time before server processes the RPC call.
int64_t latency_us() const {
if (_end_time_us == UNSET_MAGIC_NUM) {
return butil::cpuwide_time_us() - _begin_time_us;
}
return _end_time_us - _begin_time_us;
}
// Response of the RPC call (passed to CallMethod)
google::protobuf::Message* response() const { return _response; }
......
......@@ -132,6 +132,12 @@ public:
// side is properly set in the RPC sending path.
void set_deadline_us(int64_t deadline_us) { _cntl->_deadline_us = deadline_us; }
ControllerPrivateAccessor& set_begin_time_us(int64_t begin_time_us) {
_cntl->_begin_time_us = begin_time_us;
_cntl->_end_time_us = UNSET_MAGIC_NUM;
return *this;
}
private:
Controller* _cntl;
};
......
......@@ -351,6 +351,7 @@ void ProcessRpcRequest(InputMessageBase* msg_base) {
.set_local_side(socket->local_side())
.set_auth_context(socket->auth_context())
.set_request_protocol(PROTOCOL_BAIDU_STD)
.set_begin_time_us(msg->received_us())
.move_in_server_receiving_sock(socket_guard);
if (meta.has_stream_settings()) {
......
......@@ -1237,6 +1237,7 @@ void ProcessHttpRequest(InputMessageBase *msg) {
.set_local_side(socket->local_side())
.set_auth_context(socket->auth_context())
.set_request_protocol(PROTOCOL_HTTP)
.set_begin_time_us(msg->received_us())
.move_in_server_receiving_sock(socket_guard);
// Read log-id. errno may be set when input to strtoull overflows.
......
......@@ -384,6 +384,7 @@ void ProcessHuluRequest(InputMessageBase* msg_base) {
.set_local_side(socket->local_side())
.set_auth_context(socket->auth_context())
.set_request_protocol(PROTOCOL_HULU_PBRPC)
.set_begin_time_us(msg->received_us())
.move_in_server_receiving_sock(socket_guard);
if (meta.has_user_data()) {
......
......@@ -206,6 +206,7 @@ void ProcessMongoRequest(InputMessageBase* msg_base) {
.set_local_side(socket->local_side())
.set_auth_context(socket->auth_context())
.set_request_protocol(PROTOCOL_MONGO)
.set_begin_time_us(msg->received_us())
.move_in_server_receiving_sock(socket_guard);
// Tag the bthread with this server's key for
......
......@@ -262,6 +262,7 @@ void ProcessNsheadRequest(InputMessageBase* msg_base) {
.set_remote_side(socket->remote_side())
.set_local_side(socket->local_side())
.set_request_protocol(PROTOCOL_NSHEAD)
.set_begin_time_us(msg->received_us())
.move_in_server_receiving_sock(socket_guard);
// Tag the bthread with this server's key for thread_local_data().
......
......@@ -352,6 +352,7 @@ void ProcessSofaRequest(InputMessageBase* msg_base) {
.set_local_side(socket->local_side())
.set_auth_context(socket->auth_context())
.set_request_protocol(PROTOCOL_SOFA_PBRPC)
.set_begin_time_us(msg->received_us())
.move_in_server_receiving_sock(socket_guard);
// Tag the bthread with this server's key for thread_local_data().
......
......@@ -465,6 +465,7 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
.set_remote_side(socket->remote_side())
.set_local_side(socket->local_side())
.set_request_protocol(PROTOCOL_THRIFT)
.set_begin_time_us(msg_base->received_us())
.move_in_server_receiving_sock(socket_guard);
uint32_t seq_id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment