Add some metrics that match existing zebrad metrics
The metric names match those used in zebrad, so the same visualisers can be used for both nodes. See https://github.com/ZcashFoundation/zebra/issues/1381 for discussion about potential naming changes.
This commit is contained in:
parent
a79ffa3b50
commit
90f4d48307
|
@ -46,6 +46,7 @@
|
|||
#include <boost/thread.hpp>
|
||||
|
||||
#include <rust/ed25519.h>
|
||||
#include <rust/metrics.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -3237,6 +3238,7 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
|
|||
"date", date.c_str(),
|
||||
"progress", progress.c_str(),
|
||||
"cache", cache.c_str());
|
||||
MetricsGauge("block.verified.block.height", pindexNew->nHeight);
|
||||
|
||||
cvBlockChange.notify_all();
|
||||
}
|
||||
|
@ -3369,6 +3371,7 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
|
|||
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
|
||||
LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001);
|
||||
LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001);
|
||||
MetricsIncrementCounter("block.verified.block.count");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6226,6 +6229,7 @@ bool static ProcessMessage(const CChainParams& chainparams, CNode* pfrom, string
|
|||
|
||||
CInv inv(MSG_BLOCK, block.GetHash());
|
||||
LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id);
|
||||
MetricsIncrementCounter("sync.downloaded.block.count");
|
||||
|
||||
pfrom->AddInventoryKnown(inv);
|
||||
|
||||
|
@ -6244,6 +6248,8 @@ bool static ProcessMessage(const CChainParams& chainparams, CNode* pfrom, string
|
|||
LOCK(cs_main);
|
||||
Misbehaving(pfrom->GetId(), nDoS);
|
||||
}
|
||||
} else if (state.IsValid()) {
|
||||
MetricsIncrementCounter("sync.verified.block.count");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include <rust/metrics.h>
|
||||
|
||||
// Dump addresses to peers.dat and banlist.dat every 15 minutes (900s)
|
||||
#define DUMP_ADDRESSES_INTERVAL 900
|
||||
|
||||
|
@ -702,6 +704,7 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
|
|||
|
||||
if (msg.complete()) {
|
||||
msg.nTime = GetTimeMicros();
|
||||
MetricsIncrementCounter("peer.inbound.messages");
|
||||
messageHandlerCondition.notify_one();
|
||||
}
|
||||
}
|
||||
|
@ -1104,6 +1107,7 @@ void ThreadSocketHandler()
|
|||
}
|
||||
if (vNodesSize != nPrevNodeCount) {
|
||||
nPrevNodeCount = vNodesSize;
|
||||
MetricsGauge("pool.num_peers", nPrevNodeCount);
|
||||
uiInterface.NotifyNumConnectionsChanged(nPrevNodeCount);
|
||||
}
|
||||
|
||||
|
@ -2001,12 +2005,14 @@ void CNode::RecordBytesRecv(uint64_t bytes)
|
|||
{
|
||||
LOCK(cs_totalBytesRecv);
|
||||
nTotalBytesRecv += bytes;
|
||||
MetricsCounter("bytes.read", bytes);
|
||||
}
|
||||
|
||||
void CNode::RecordBytesSent(uint64_t bytes)
|
||||
{
|
||||
LOCK(cs_totalBytesSent);
|
||||
nTotalBytesSent += bytes;
|
||||
MetricsCounter("bytes.written", bytes);
|
||||
|
||||
uint64_t now = GetTime();
|
||||
if (nMaxOutboundCycleStartTime + nMaxOutboundTimeframe < now)
|
||||
|
@ -2280,6 +2286,7 @@ void CNode::AbortMessage() UNLOCK_FUNCTION(cs_vSend)
|
|||
|
||||
void CNode::EndMessage() UNLOCK_FUNCTION(cs_vSend)
|
||||
{
|
||||
MetricsIncrementCounter("peer.outbound.messages");
|
||||
// The -*messagestest options are intentionally not documented in the help message,
|
||||
// since they are only used during development to debug the networking code and are
|
||||
// not intended for end-users.
|
||||
|
|
Loading…
Reference in New Issue