Skip to content

Commit 79165d5

Browse files
authored
chore: Observability improvements to node logs and metrics | NPG-7984 (#542)
# Description Update a couple of log messages to clarify fragments rejected from the mempool. Convert `lastBlockTx` prometheus metric from being a gauge into counter. Add docstrings to clarify the meaning of prometheus metrics related to transactions. ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) ## Checklist - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
1 parent cb2839a commit 79165d5

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/jormungandr/jormungandr/src/fragment/pool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ impl Pool {
9696
id: FragmentId,
9797
) -> Result<(), FragmentRejectionReason> {
9898
if self.logs.exists(id) {
99-
tracing::debug!("fragment is already logged");
99+
tracing::debug!("fragment is already logged, excluding from the pool");
100100
return Err(FragmentRejectionReason::FragmentAlreadyInLog);
101101
}
102102

103103
if !is_fragment_valid(fragment) {
104-
tracing::debug!("fragment is invalid, not including to the pool");
104+
tracing::debug!("fragment is invalid, excluding from the pool");
105105
return Err(FragmentRejectionReason::FragmentInvalid);
106106
}
107107

@@ -122,7 +122,7 @@ impl Pool {
122122
}
123123
}
124124

125-
tracing::debug!("including fragment to the pool");
125+
tracing::debug!("fragment is valid for pool entry");
126126
Ok(())
127127
}
128128

src/jormungandr/jormungandr/src/metrics/backends/prometheus_exporter.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ type UIntGauge = GenericGauge<AtomicU64>;
1717
pub struct Prometheus {
1818
registry: Registry,
1919

20+
// Total number of tx accepted for a given block
2021
tx_recv_cnt: IntCounter,
22+
// Total number of tx rejected for a given block
2123
tx_rejected_cnt: IntCounter,
24+
// Mempool usage ratio for a given block
2225
mempool_usage_ratio: Gauge,
26+
// Total number of tx in the mempool for a given block
2327
mempool_tx_count: UIntGauge,
2428
votes_casted_cnt: IntCounter,
2529
block_recv_cnt: IntCounter,
@@ -28,7 +32,8 @@ pub struct Prometheus {
2832
peer_available_cnt: UIntGauge,
2933
peer_total_cnt: UIntGauge,
3034
slot_start_time: UIntGauge,
31-
block_tx_count: UIntGauge,
35+
// Total number of tx for a given block
36+
block_tx_count: IntCounter,
3237
block_input_sum: UIntGauge,
3338
block_fee_sum: UIntGauge,
3439
block_content_size: UIntGauge,
@@ -116,7 +121,7 @@ impl Default for Prometheus {
116121
registry
117122
.register(Box::new(slot_start_time.clone()))
118123
.unwrap();
119-
let block_tx_count = UIntGauge::new("lastBlockTx", "lastBlockTx").unwrap();
124+
let block_tx_count = IntCounter::new("lastBlockTx", "lastBlockTx").unwrap();
120125
registry.register(Box::new(block_tx_count.clone())).unwrap();
121126
let block_input_sum = UIntGauge::new("lastBlockInputTime", "lastBlockInputTime").unwrap();
122127
registry
@@ -280,7 +285,7 @@ impl MetricsBackend for Prometheus {
280285
.expect("should be good");
281286

282287
self.votes_casted_cnt.inc_by(votes_casted);
283-
self.block_tx_count.set(block_tx_count);
288+
self.block_tx_count.inc_by(block_tx_count);
284289
self.block_input_sum.set(block_input_sum.0);
285290
self.block_fee_sum.set(block_fee_sum.0);
286291
self.block_content_size

0 commit comments

Comments
 (0)