metrics: Rename metrics with consistent naming scheme
- Add zcash. prefix to common metrics. - Use .total suffix for accumulating counters instead of .count. - Group names where possible. - Shorten names where possible (and still clear).
This commit is contained in:
parent
0f9e4b9472
commit
e2e5df28a9
|
@ -36,20 +36,20 @@ restarting `zcashd` you can then test the endpoint by querying it:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ curl http://127.0.0.1:<port>
|
$ curl http://127.0.0.1:<port>
|
||||||
# TYPE peer_outbound_messages counter
|
# TYPE zcash_net_out_messages counter
|
||||||
peer_outbound_messages 181
|
zcash_net_out_messages 181
|
||||||
|
|
||||||
# TYPE bytes_read counter
|
# TYPE zcash_net_in_bytes_total counter
|
||||||
bytes_read 3701998
|
zcash_net_in_bytes_total 3701998
|
||||||
|
|
||||||
# TYPE peer_inbound_messages counter
|
# TYPE zcash_net_in_messages counter
|
||||||
peer_inbound_messages 184
|
zcash_net_in_messages 184
|
||||||
|
|
||||||
# TYPE zcashd_build_info counter
|
# TYPE zcashd_build_info counter
|
||||||
zcashd_build_info{version="v4.2.0"} 1
|
zcashd_build_info{version="v4.2.0"} 1
|
||||||
|
|
||||||
# TYPE block_verified_block_count counter
|
# TYPE zcash_chain_verified_block_total counter
|
||||||
block_verified_block_count 162
|
zcash_chain_verified_block_total 162
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
20
src/main.cpp
20
src/main.cpp
|
@ -1694,9 +1694,9 @@ bool AcceptToMemoryPool(
|
||||||
|
|
||||||
pool.EnsureSizeLimit();
|
pool.EnsureSizeLimit();
|
||||||
|
|
||||||
MetricsGauge("mempool.size.transactions", mempool.size());
|
MetricsGauge("zcash.mempool.size.transactions", mempool.size());
|
||||||
MetricsGauge("mempool.size.bytes", mempool.GetTotalTxSize());
|
MetricsGauge("zcash.mempool.size.bytes", mempool.GetTotalTxSize());
|
||||||
MetricsGauge("mempool.usage.bytes", mempool.DynamicMemoryUsage());
|
MetricsGauge("zcash.mempool.usage.bytes", mempool.DynamicMemoryUsage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3251,13 +3251,13 @@ struct PoolMetrics {
|
||||||
do { \
|
do { \
|
||||||
if (poolMetrics.commitments) { \
|
if (poolMetrics.commitments) { \
|
||||||
MetricsStaticGauge( \
|
MetricsStaticGauge( \
|
||||||
"pool.commitments", \
|
"zcash.pool.commitments", \
|
||||||
poolMetrics.commitments.value(), \
|
poolMetrics.commitments.value(), \
|
||||||
"name", poolName); \
|
"name", poolName); \
|
||||||
} \
|
} \
|
||||||
if (poolMetrics.value) { \
|
if (poolMetrics.value) { \
|
||||||
MetricsStaticGauge( \
|
MetricsStaticGauge( \
|
||||||
"pool.value.zatoshis", \
|
"zcash.pool.value.zatoshis", \
|
||||||
poolMetrics.value.value(), \
|
poolMetrics.value.value(), \
|
||||||
"name", poolName); \
|
"name", poolName); \
|
||||||
} \
|
} \
|
||||||
|
@ -3293,7 +3293,7 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
|
||||||
auto sproutPool = PoolMetrics::Sprout(pindexNew, pcoinsTip);
|
auto sproutPool = PoolMetrics::Sprout(pindexNew, pcoinsTip);
|
||||||
auto saplingPool = PoolMetrics::Sapling(pindexNew, pcoinsTip);
|
auto saplingPool = PoolMetrics::Sapling(pindexNew, pcoinsTip);
|
||||||
|
|
||||||
MetricsGauge("block.verified.block.height", pindexNew->nHeight);
|
MetricsGauge("zcash.chain.verified.block.height", pindexNew->nHeight);
|
||||||
RenderPoolMetrics("sprout", sproutPool);
|
RenderPoolMetrics("sprout", sproutPool);
|
||||||
RenderPoolMetrics("sapling", saplingPool);
|
RenderPoolMetrics("sapling", saplingPool);
|
||||||
|
|
||||||
|
@ -3428,8 +3428,8 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
|
||||||
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
|
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 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);
|
LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001);
|
||||||
MetricsIncrementCounter("block.verified.block.count");
|
MetricsIncrementCounter("zcash.chain.verified.block.total");
|
||||||
MetricsHistogram("block.verified.block.seconds", (nTime6 - nTime1) * 0.000001);
|
MetricsHistogram("zcash.chain.verified.block.seconds", (nTime6 - nTime1) * 0.000001);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6287,7 +6287,7 @@ bool static ProcessMessage(const CChainParams& chainparams, CNode* pfrom, string
|
||||||
|
|
||||||
CInv inv(MSG_BLOCK, block.GetHash());
|
CInv inv(MSG_BLOCK, block.GetHash());
|
||||||
LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id);
|
LogPrint("net", "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id);
|
||||||
MetricsIncrementCounter("sync.downloaded.block.count");
|
MetricsIncrementCounter("zcash.sync.block.downloaded.total");
|
||||||
|
|
||||||
pfrom->AddInventoryKnown(inv);
|
pfrom->AddInventoryKnown(inv);
|
||||||
|
|
||||||
|
@ -6307,7 +6307,7 @@ bool static ProcessMessage(const CChainParams& chainparams, CNode* pfrom, string
|
||||||
Misbehaving(pfrom->GetId(), nDoS);
|
Misbehaving(pfrom->GetId(), nDoS);
|
||||||
}
|
}
|
||||||
} else if (state.IsValid()) {
|
} else if (state.IsValid()) {
|
||||||
MetricsIncrementCounter("sync.verified.block.count");
|
MetricsIncrementCounter("zcash.sync.block.verified.total");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
14
src/net.cpp
14
src/net.cpp
|
@ -705,9 +705,9 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
|
||||||
if (msg.complete()) {
|
if (msg.complete()) {
|
||||||
msg.nTime = GetTimeMicros();
|
msg.nTime = GetTimeMicros();
|
||||||
std::string strCommand = SanitizeString(msg.hdr.GetCommand());
|
std::string strCommand = SanitizeString(msg.hdr.GetCommand());
|
||||||
MetricsIncrementCounter("peer.inbound.messages", "command", strCommand.c_str());
|
MetricsIncrementCounter("zcash.net.in.messages", "command", strCommand.c_str());
|
||||||
MetricsCounter(
|
MetricsCounter(
|
||||||
"peer.inbound.bytes", msg.hdr.nMessageSize,
|
"zcash.net.in.bytes", msg.hdr.nMessageSize,
|
||||||
"command", strCommand.c_str());
|
"command", strCommand.c_str());
|
||||||
messageHandlerCondition.notify_one();
|
messageHandlerCondition.notify_one();
|
||||||
}
|
}
|
||||||
|
@ -1111,7 +1111,7 @@ void ThreadSocketHandler()
|
||||||
}
|
}
|
||||||
if (vNodesSize != nPrevNodeCount) {
|
if (vNodesSize != nPrevNodeCount) {
|
||||||
nPrevNodeCount = vNodesSize;
|
nPrevNodeCount = vNodesSize;
|
||||||
MetricsGauge("pool.num_peers", nPrevNodeCount);
|
MetricsGauge("zcash.net.peers", nPrevNodeCount);
|
||||||
uiInterface.NotifyNumConnectionsChanged(nPrevNodeCount);
|
uiInterface.NotifyNumConnectionsChanged(nPrevNodeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2009,14 +2009,14 @@ void CNode::RecordBytesRecv(uint64_t bytes)
|
||||||
{
|
{
|
||||||
LOCK(cs_totalBytesRecv);
|
LOCK(cs_totalBytesRecv);
|
||||||
nTotalBytesRecv += bytes;
|
nTotalBytesRecv += bytes;
|
||||||
MetricsCounter("bytes.read", bytes);
|
MetricsCounter("zcash.net.in.bytes.total", bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNode::RecordBytesSent(uint64_t bytes)
|
void CNode::RecordBytesSent(uint64_t bytes)
|
||||||
{
|
{
|
||||||
LOCK(cs_totalBytesSent);
|
LOCK(cs_totalBytesSent);
|
||||||
nTotalBytesSent += bytes;
|
nTotalBytesSent += bytes;
|
||||||
MetricsCounter("bytes.written", bytes);
|
MetricsCounter("zcash.net.out.bytes.total", bytes);
|
||||||
|
|
||||||
uint64_t now = GetTime();
|
uint64_t now = GetTime();
|
||||||
if (nMaxOutboundCycleStartTime + nMaxOutboundTimeframe < now)
|
if (nMaxOutboundCycleStartTime + nMaxOutboundTimeframe < now)
|
||||||
|
@ -2292,7 +2292,7 @@ void CNode::AbortMessage() UNLOCK_FUNCTION(cs_vSend)
|
||||||
|
|
||||||
void CNode::EndMessage() UNLOCK_FUNCTION(cs_vSend)
|
void CNode::EndMessage() UNLOCK_FUNCTION(cs_vSend)
|
||||||
{
|
{
|
||||||
MetricsIncrementCounter("peer.outbound.messages", "command", strSendCommand.c_str());
|
MetricsIncrementCounter("zcash.net.out.messages", "command", strSendCommand.c_str());
|
||||||
// The -*messagestest options are intentionally not documented in the help message,
|
// 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
|
// since they are only used during development to debug the networking code and are
|
||||||
// not intended for end-users.
|
// not intended for end-users.
|
||||||
|
@ -2327,7 +2327,7 @@ void CNode::EndMessage() UNLOCK_FUNCTION(cs_vSend)
|
||||||
ssSend.GetAndClear(*it);
|
ssSend.GetAndClear(*it);
|
||||||
nSendSize += (*it).size();
|
nSendSize += (*it).size();
|
||||||
MetricsCounter(
|
MetricsCounter(
|
||||||
"peer.outbound.bytes", (*it).size(),
|
"zcash.net.out.bytes", (*it).size(),
|
||||||
"command", strSendCommand.c_str());
|
"command", strSendCommand.c_str());
|
||||||
strSendCommand.clear();
|
strSendCommand.clear();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue