mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 02:55:50 +00:00
log request and duration for every RPC call
This commit is contained in:
@@ -377,6 +377,25 @@ ServerHandlerImp::onStopped(Server&)
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void
|
||||||
|
logDuration(
|
||||||
|
Json::Value const& request,
|
||||||
|
T const& duration,
|
||||||
|
beast::Journal& journal)
|
||||||
|
{
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
auto const level = (duration >= 10s)
|
||||||
|
? journal.error()
|
||||||
|
: (duration >= 1s) ? journal.warn() : journal.debug();
|
||||||
|
|
||||||
|
JLOG(level) << "RPC request processing duration = "
|
||||||
|
<< std::chrono::duration_cast<std::chrono::microseconds>(
|
||||||
|
duration)
|
||||||
|
.count()
|
||||||
|
<< " microseconds. request = " << request;
|
||||||
|
}
|
||||||
|
|
||||||
Json::Value
|
Json::Value
|
||||||
ServerHandlerImp::processSession(
|
ServerHandlerImp::processSession(
|
||||||
std::shared_ptr<WSSession> const& session,
|
std::shared_ptr<WSSession> const& session,
|
||||||
@@ -458,7 +477,10 @@ ServerHandlerImp::processSession(
|
|||||||
jv,
|
jv,
|
||||||
{is->user(), is->forwarded_for()}};
|
{is->user(), is->forwarded_for()}};
|
||||||
|
|
||||||
|
auto start = std::chrono::system_clock::now();
|
||||||
RPC::doCommand(context, jr[jss::result]);
|
RPC::doCommand(context, jr[jss::result]);
|
||||||
|
auto end = std::chrono::system_clock::now();
|
||||||
|
logDuration(jv, end - start, m_journal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception const& ex)
|
catch (std::exception const& ex)
|
||||||
@@ -851,7 +873,11 @@ ServerHandlerImp::processRequest(
|
|||||||
params,
|
params,
|
||||||
{user, forwardedFor}};
|
{user, forwardedFor}};
|
||||||
Json::Value result;
|
Json::Value result;
|
||||||
|
auto start = std::chrono::system_clock::now();
|
||||||
RPC::doCommand(context, result);
|
RPC::doCommand(context, result);
|
||||||
|
auto end = std::chrono::system_clock::now();
|
||||||
|
logDuration(params, end - start, m_journal);
|
||||||
|
|
||||||
usage.charge(loadType);
|
usage.charge(loadType);
|
||||||
if (usage.warn())
|
if (usage.warn())
|
||||||
result[jss::warning] = jss::load;
|
result[jss::warning] = jss::load;
|
||||||
|
|||||||
Reference in New Issue
Block a user