mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 15:05:53 +00:00
Report duration in current state.
This commit is contained in:
committed by
Nik Bougalis
parent
ad5c5f1969
commit
fbdbffed67
@@ -58,6 +58,9 @@
|
|||||||
#include <ripple/basics/make_lock.h>
|
#include <ripple/basics/make_lock.h>
|
||||||
#include <boost/asio/steady_timer.hpp>
|
#include <boost/asio/steady_timer.hpp>
|
||||||
#include <boost/asio/ip/host_name.hpp>
|
#include <boost/asio/ip/host_name.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <tuple>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
@@ -149,12 +152,19 @@ class NetworkOPsImp final
|
|||||||
*/
|
*/
|
||||||
void mode (OperatingMode om);
|
void mode (OperatingMode om);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Json-formatted state accounting data.
|
||||||
|
* 1st member: state accounting object.
|
||||||
|
* 2nd member: duration in current state.
|
||||||
|
*/
|
||||||
|
using StateCountersJson = std::pair <Json::Value, std::string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output state counters in JSON format.
|
* Output state counters in JSON format.
|
||||||
*
|
*
|
||||||
* @return JSON object.
|
* @return JSON object.
|
||||||
*/
|
*/
|
||||||
Json::Value json() const;
|
StateCountersJson json() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Server fees published on `server` subscription
|
//! Server fees published on `server` subscription
|
||||||
@@ -2353,7 +2363,8 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin, bool counters)
|
|||||||
info[jss::published_ledger] = lpPublished->info().seq;
|
info[jss::published_ledger] = lpPublished->info().seq;
|
||||||
}
|
}
|
||||||
|
|
||||||
info[jss::state_accounting] = accounting_.json();
|
std::tie(info[jss::state_accounting],
|
||||||
|
info[jss::server_state_duration_us]) = accounting_.json();
|
||||||
info[jss::uptime] = UptimeClock::now().time_since_epoch().count();
|
info[jss::uptime] = UptimeClock::now().time_since_epoch().count();
|
||||||
info[jss::jq_trans_overflow] = std::to_string(
|
info[jss::jq_trans_overflow] = std::to_string(
|
||||||
app_.overlay().getJqTransOverflow());
|
app_.overlay().getJqTransOverflow());
|
||||||
@@ -3338,7 +3349,8 @@ void NetworkOPsImp::StateAccounting::mode (OperatingMode om)
|
|||||||
start_ = now;
|
start_ = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value NetworkOPsImp::StateAccounting::json() const
|
NetworkOPsImp::StateAccounting::StateCountersJson
|
||||||
|
NetworkOPsImp::StateAccounting::json() const
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock (mutex_);
|
std::unique_lock<std::mutex> lock (mutex_);
|
||||||
|
|
||||||
@@ -3348,8 +3360,9 @@ Json::Value NetworkOPsImp::StateAccounting::json() const
|
|||||||
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
counters[mode].dur += std::chrono::duration_cast<
|
auto const current = std::chrono::duration_cast<
|
||||||
std::chrono::microseconds>(std::chrono::system_clock::now() - start);
|
std::chrono::microseconds>(std::chrono::system_clock::now() - start);
|
||||||
|
counters[mode].dur += current;
|
||||||
|
|
||||||
Json::Value ret = Json::objectValue;
|
Json::Value ret = Json::objectValue;
|
||||||
|
|
||||||
@@ -3362,7 +3375,7 @@ Json::Value NetworkOPsImp::StateAccounting::json() const
|
|||||||
state[jss::duration_us] = std::to_string(counters[i].dur.count());
|
state[jss::duration_us] = std::to_string(counters[i].dur.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return {ret, std::to_string(current.count())};
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -400,6 +400,7 @@ JSS ( seq ); // in: LedgerEntry;
|
|||||||
// ValidatorList
|
// ValidatorList
|
||||||
JSS ( seqNum ); // out: LedgerToJson
|
JSS ( seqNum ); // out: LedgerToJson
|
||||||
JSS ( server_state ); // out: NetworkOPs
|
JSS ( server_state ); // out: NetworkOPs
|
||||||
|
JSS ( server_state_duration_us ); // out: NetworkOPs
|
||||||
JSS ( server_status ); // out: NetworkOPs
|
JSS ( server_status ); // out: NetworkOPs
|
||||||
JSS ( settle_delay ); // out: AccountChannels
|
JSS ( settle_delay ); // out: AccountChannels
|
||||||
JSS ( severity ); // in: LogLevel
|
JSS ( severity ); // in: LogLevel
|
||||||
|
|||||||
Reference in New Issue
Block a user