metrics: Use labels for pool statistics
It's very likely that you'll want to operate over common pool statistics together.
This commit is contained in:
parent
78b83fd6e9
commit
0f9e4b9472
20
src/main.cpp
20
src/main.cpp
|
@ -3217,7 +3217,7 @@ void PruneAndFlush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PoolMetrics {
|
struct PoolMetrics {
|
||||||
size_t commitments;
|
std::optional<size_t> commitments;
|
||||||
std::optional<CAmount> value;
|
std::optional<CAmount> value;
|
||||||
|
|
||||||
static PoolMetrics Sprout(CBlockIndex *pindex, CCoinsViewCache *view) {
|
static PoolMetrics Sprout(CBlockIndex *pindex, CCoinsViewCache *view) {
|
||||||
|
@ -3239,6 +3239,8 @@ struct PoolMetrics {
|
||||||
SaplingMerkleTree saplingTree;
|
SaplingMerkleTree saplingTree;
|
||||||
if (view->GetSaplingAnchorAt(pindex->hashFinalSaplingRoot, saplingTree)) {
|
if (view->GetSaplingAnchorAt(pindex->hashFinalSaplingRoot, saplingTree)) {
|
||||||
stats.commitments = saplingTree.size();
|
stats.commitments = saplingTree.size();
|
||||||
|
} else {
|
||||||
|
stats.commitments = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
|
@ -3247,13 +3249,17 @@ struct PoolMetrics {
|
||||||
|
|
||||||
#define RenderPoolMetrics(poolName, poolMetrics) \
|
#define RenderPoolMetrics(poolName, poolMetrics) \
|
||||||
do { \
|
do { \
|
||||||
static constexpr const char* poolCommitments = \
|
if (poolMetrics.commitments) { \
|
||||||
"pool." poolName ".commitments"; \
|
MetricsStaticGauge( \
|
||||||
static constexpr const char* poolValue = \
|
"pool.commitments", \
|
||||||
"pool." poolName ".value.zatoshis"; \
|
poolMetrics.commitments.value(), \
|
||||||
MetricsGauge(poolCommitments, poolMetrics.commitments); \
|
"name", poolName); \
|
||||||
|
} \
|
||||||
if (poolMetrics.value) { \
|
if (poolMetrics.value) { \
|
||||||
MetricsGauge(poolValue, poolMetrics.value.value()); \
|
MetricsStaticGauge( \
|
||||||
|
"pool.value.zatoshis", \
|
||||||
|
poolMetrics.value.value(), \
|
||||||
|
"name", poolName); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue