metrics: Add gauge for the height to which the wallet is synced

This commit is contained in:
Jack Grigg 2022-09-21 19:08:45 +00:00
parent 34f0a973c7
commit 39401964d2
2 changed files with 7 additions and 0 deletions

View File

@ -19,6 +19,7 @@ has a memory limit of 100 MiB.
- (counter) `zcashd.wallet.batchscanner.outputs.scanned` - (counter) `zcashd.wallet.batchscanner.outputs.scanned`
- (gauge) `zcashd.wallet.batchscanner.size.transactions` - (gauge) `zcashd.wallet.batchscanner.size.transactions`
- (gauge) `zcashd.wallet.batchscanner.usage.bytes` - (gauge) `zcashd.wallet.batchscanner.usage.bytes`
- (gauge) `zcashd.wallet.synced.block.height`
RPC Interface RPC Interface
------------- -------------

View File

@ -17,10 +17,14 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <rust/metrics.h>
using namespace boost::placeholders; using namespace boost::placeholders;
static CMainSignals g_signals; static CMainSignals g_signals;
static constexpr const char* METRIC_WALLET_SYNCED_HEIGHT = "zcashd.wallet.synced.block.height";
CMainSignals& GetMainSignals() CMainSignals& GetMainSignals()
{ {
return g_signals; return g_signals;
@ -447,6 +451,7 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip)
// On to the next block! // On to the next block!
pindexLastTip = pindexLastTip->pprev; pindexLastTip = pindexLastTip->pprev;
MetricsGauge(METRIC_WALLET_SYNCED_HEIGHT, pindexLastTip->nHeight);
} }
// Notify block connections // Notify block connections
@ -513,6 +518,7 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip)
// This block is done! // This block is done!
pindexLastTip = blockData.pindex; pindexLastTip = blockData.pindex;
MetricsGauge(METRIC_WALLET_SYNCED_HEIGHT, pindexLastTip->nHeight);
assert(blockStack.rbegin() != blockStackScanned); assert(blockStack.rbegin() != blockStackScanned);
blockStack.pop_back(); blockStack.pop_back();
} }