Report the validated and publish ledger ages over insight

This commit is contained in:
mbhandary
2019-11-27 16:12:10 -05:00
committed by Nik Bougalis
parent 9fcc30df89
commit 9294a07362
2 changed files with 30 additions and 0 deletions

View File

@@ -371,6 +371,35 @@ private:
// without first wiping the database.
LedgerIndex const max_ledger_difference_ {1000000};
private:
struct Stats
{
template <class Handler>
Stats (Handler const& handler, beast::insight::Collector::ptr const& collector)
: hook (collector->make_hook (handler))
, validatedLedgerAge (collector->make_gauge ("LedgerMaster", "Validated_Ledger_Age"))
, publishedLedgerAge (collector->make_gauge ("LedgerMaster", "Published_Ledger_Age"))
{ }
beast::insight::Hook hook;
beast::insight::Gauge validatedLedgerAge;
beast::insight::Gauge publishedLedgerAge;
};
Stats m_stats;
private:
void collect_metrics()
{
std::lock_guard lock (m_mutex);
m_stats.validatedLedgerAge.set(getValidatedLedgerAge().count());
m_stats.publishedLedgerAge.set(getPublishedLedgerAge().count());
}
};
} // ripple

View File

@@ -155,6 +155,7 @@ LedgerMaster::LedgerMaster (Application& app, Stopwatch& stopwatch,
, ledger_fetch_size_ (app_.config().getValueFor(SizedItem::ledgerFetch))
, fetch_packs_ ("FetchPack", 65536, std::chrono::seconds {45}, stopwatch,
app_.journal("TaggedCache"))
, m_stats(std::bind (&LedgerMaster::collect_metrics, this),collector)
{
}