diff --git a/crates/core/src/db/datastore/locking_tx_datastore/mod.rs b/crates/core/src/db/datastore/locking_tx_datastore/mod.rs index e0049b3fe0..386136e94a 100644 --- a/crates/core/src/db/datastore/locking_tx_datastore/mod.rs +++ b/crates/core/src/db/datastore/locking_tx_datastore/mod.rs @@ -2115,39 +2115,45 @@ impl traits::MutTx for Locking { } fn rollback_mut_tx(&self, ctx: &ExecutionContext, mut tx: Self::MutTxId) { + let txn_type = &ctx.txn_type(); + let db = &ctx.database(); + let reducer = ctx.reducer_name().unwrap_or_default(); let elapsed_time = tx.timer.elapsed(); let cpu_time = elapsed_time - tx.lock_wait_time; DB_METRICS - .rdb_num_txns_rolledback - .with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or("")) + .rdb_num_txns + .with_label_values(txn_type, db, reducer, &false) .inc(); DB_METRICS .rdb_txn_cpu_time_sec - .with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or("")) + .with_label_values(txn_type, db, reducer) .observe(cpu_time.as_secs_f64()); DB_METRICS .rdb_txn_elapsed_time_sec - .with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or("")) + .with_label_values(txn_type, db, reducer) .observe(elapsed_time.as_secs_f64()); tx.lock.rollback(); } fn commit_mut_tx(&self, ctx: &ExecutionContext, mut tx: Self::MutTxId) -> super::Result> { + let txn_type = &ctx.txn_type(); + let db = &ctx.database(); + let reducer = ctx.reducer_name().unwrap_or_default(); let elapsed_time = tx.timer.elapsed(); let cpu_time = elapsed_time - tx.lock_wait_time; // Note, we record empty transactions in our metrics. // That is, transactions that don't write any rows to the commit log. DB_METRICS - .rdb_num_txns_committed - .with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or("")) + .rdb_num_txns + .with_label_values(txn_type, db, reducer, &true) .inc(); DB_METRICS .rdb_txn_cpu_time_sec - .with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or("")) + .with_label_values(txn_type, db, reducer) .observe(cpu_time.as_secs_f64()); DB_METRICS .rdb_txn_elapsed_time_sec - .with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or("")) + .with_label_values(txn_type, db, reducer) .observe(elapsed_time.as_secs_f64()); tx.lock.commit() } diff --git a/crates/core/src/db/db_metrics/mod.rs b/crates/core/src/db/db_metrics/mod.rs index 969acd8810..2ec94f1eee 100644 --- a/crates/core/src/db/db_metrics/mod.rs +++ b/crates/core/src/db/db_metrics/mod.rs @@ -86,15 +86,10 @@ metrics_group!( #[labels(txn_type: TransactionType, db: Address, reducer: str, table_id: u32)] pub rdb_num_index_seeks: IntCounterVec, - #[name = spacetime_num_txns_committed_cumulative] - #[help = "The cumulative number of committed transactions"] - #[labels(txn_type: TransactionType, db: Address, reducer: str)] - pub rdb_num_txns_committed: IntCounterVec, - - #[name = spacetime_num_txns_rolledback_cumulative] - #[help = "The cumulative number of rolled back transactions"] - #[labels(txn_type: TransactionType, db: Address, reducer: str)] - pub rdb_num_txns_rolledback: IntCounterVec, + #[name = spacetime_num_txns_cumulative] + #[help = "The cumulative number of transactions, including both commits and rollbacks"] + #[labels(txn_type: TransactionType, db: Address, reducer: str, committed: bool)] + pub rdb_num_txns: IntCounterVec, #[name = spacetime_txn_elapsed_time_sec] #[help = "The total elapsed (wall) time of a transaction (in seconds)"] diff --git a/crates/core/src/util/typed_prometheus.rs b/crates/core/src/util/typed_prometheus.rs index 10c3180ec5..ef3e185948 100644 --- a/crates/core/src/util/typed_prometheus.rs +++ b/crates/core/src/util/typed_prometheus.rs @@ -122,6 +122,7 @@ impl_prometheusvalue_string!( Address, TransactionType, AbiCall, + bool, u8, u16, u32,