Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/core/src/db/commit_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ impl CommitLogMut {

let workload = &ctx.workload();
let db = &ctx.database();
let reducer = &ctx.reducer_name().unwrap_or_default();
let reducer_or_query = &ctx.reducer_or_query();

for record in &tx_data.records {
let table_id: u32 = record.table_id.into();
Expand All @@ -340,7 +340,7 @@ impl CommitLogMut {
// Increment rows inserted metric
DB_METRICS
.rdb_num_rows_inserted
.with_label_values(workload, db, reducer, &table_id)
.with_label_values(workload, db, reducer_or_query, &table_id)
.inc();
// Increment table rows gauge
DB_METRICS.rdb_num_table_rows.with_label_values(db, &table_id).inc();
Expand All @@ -350,7 +350,7 @@ impl CommitLogMut {
// Increment rows deleted metric
DB_METRICS
.rdb_num_rows_deleted
.with_label_values(workload, db, reducer, &table_id)
.with_label_values(workload, db, reducer_or_query, &table_id)
.inc();
// Decrement table rows gauge
DB_METRICS.rdb_num_table_rows.with_label_values(db, &table_id).dec();
Expand Down
14 changes: 7 additions & 7 deletions crates/core/src/db/datastore/locking_tx_datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ impl Drop for Iter<'_> {
.with_label_values(
&self.ctx.workload(),
&self.ctx.database(),
self.ctx.reducer_name().unwrap_or_default(),
self.ctx.reducer_or_query(),
&self.table_id.into(),
)
.inc_by(self.num_committed_rows_fetched);
Expand Down Expand Up @@ -1843,7 +1843,7 @@ impl Drop for IndexSeekIterInner<'_> {
.with_label_values(
&self.ctx.workload(),
&self.ctx.database(),
self.ctx.reducer_name().unwrap_or_default(),
self.ctx.reducer_or_query(),
&self.table_id.0,
)
.inc();
Expand All @@ -1854,7 +1854,7 @@ impl Drop for IndexSeekIterInner<'_> {
.with_label_values(
&self.ctx.workload(),
&self.ctx.database(),
self.ctx.reducer_name().unwrap_or_default(),
self.ctx.reducer_or_query(),
&self.table_id.0,
)
.inc_by(self.committed_rows.as_ref().map_or(0, |iter| iter.keys_scanned()));
Expand All @@ -1865,7 +1865,7 @@ impl Drop for IndexSeekIterInner<'_> {
.with_label_values(
&self.ctx.workload(),
&self.ctx.database(),
self.ctx.reducer_name().unwrap_or_default(),
self.ctx.reducer_or_query(),
&self.table_id.0,
)
.inc_by(self.num_committed_rows_fetched);
Expand Down Expand Up @@ -1917,7 +1917,7 @@ impl Drop for CommittedIndexIter<'_> {
.with_label_values(
&self.ctx.workload(),
&self.ctx.database(),
self.ctx.reducer_name().unwrap_or_default(),
self.ctx.reducer_or_query(),
&self.table_id.0,
)
.inc();
Expand All @@ -1928,7 +1928,7 @@ impl Drop for CommittedIndexIter<'_> {
.with_label_values(
&self.ctx.workload(),
&self.ctx.database(),
self.ctx.reducer_name().unwrap_or_default(),
self.ctx.reducer_or_query(),
&self.table_id.0,
)
.inc_by(self.committed_rows.keys_scanned());
Expand All @@ -1939,7 +1939,7 @@ impl Drop for CommittedIndexIter<'_> {
.with_label_values(
&self.ctx.workload(),
&self.ctx.database(),
self.ctx.reducer_name().unwrap_or_default(),
self.ctx.reducer_or_query(),
&self.table_id.0,
)
.inc_by(self.num_committed_rows_fetched);
Expand Down
12 changes: 6 additions & 6 deletions crates/core/src/db/db_metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,27 @@ metrics_group!(

#[name = spacetime_num_rows_inserted_cumulative]
#[help = "The cumulative number of rows inserted into a table"]
#[labels(txn_type: WorkloadType, db: Address, reducer: str, table_id: u32)]
#[labels(txn_type: WorkloadType, db: Address, reducer_or_query: str, table_id: u32)]
pub rdb_num_rows_inserted: IntCounterVec,

#[name = spacetime_num_rows_deleted_cumulative]
#[help = "The cumulative number of rows deleted from a table"]
#[labels(txn_type: WorkloadType, db: Address, reducer: str, table_id: u32)]
#[labels(txn_type: WorkloadType, db: Address, reducer_or_query: str, table_id: u32)]
pub rdb_num_rows_deleted: IntCounterVec,

#[name = spacetime_num_rows_fetched_cumulative]
#[help = "The cumulative number of rows fetched from a table"]
#[labels(txn_type: WorkloadType, db: Address, reducer: str, table_id: u32)]
#[labels(txn_type: WorkloadType, db: Address, reducer_or_query: str, table_id: u32)]
pub rdb_num_rows_fetched: IntCounterVec,

#[name = spacetime_num_index_keys_scanned_cumulative]
#[help = "The cumulative number of keys scanned from an index"]
#[labels(txn_type: WorkloadType, db: Address, reducer: str, table_id: u32)]
#[labels(txn_type: WorkloadType, db: Address, reducer_or_query: str, table_id: u32)]
pub rdb_num_keys_scanned: IntCounterVec,

#[name = spacetime_num_index_seeks_cumulative]
#[help = "The cumulative number of index seeks"]
#[labels(txn_type: WorkloadType, db: Address, reducer: str, table_id: u32)]
#[labels(txn_type: WorkloadType, db: Address, reducer_or_query: str, table_id: u32)]
pub rdb_num_index_seeks: IntCounterVec,

#[name = spacetime_num_txns_cumulative]
Expand All @@ -105,7 +105,7 @@ metrics_group!(

#[name = spacetime_wasm_abi_call_duration_sec]
#[help = "The total duration of a spacetime wasm abi call (in seconds); includes row serialization and copying into wasm memory"]
#[labels(txn_type: WorkloadType, db: Address, reducer: str, call: AbiCall)]
#[labels(db: Address, reducer: str, call: AbiCall)]
pub wasm_abi_call_duration_sec: HistogramVec,

#[name = spacetime_message_log_size_bytes]
Expand Down
8 changes: 8 additions & 0 deletions crates/core/src/execution_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ impl<'a> ExecutionContext<'a> {
self.query_debug_info
}

/// If this is a reducer context, returns the name of the reducer.
/// If this is a query context, returns the query string.
#[inline]
pub fn reducer_or_query(&self) -> &str {
self.reducer
.unwrap_or_else(|| self.query_debug_info.map(|info| info.source()).unwrap_or_default())
}

/// Returns the type of workload that is being executed.
#[inline]
pub fn workload(&self) -> WorkloadType {
Expand Down
3 changes: 1 addition & 2 deletions crates/core/src/host/wasmtime/wasm_instance_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,11 @@ impl WasmInstanceEnv {
/// Gather the appropriate metadata and log a wasm_abi_call_duration_ns with the given AbiCall & duration
fn start_abi_call_timer(&self, call: AbiCall) -> prometheus::HistogramTimer {
let ctx = self.reducer_context();
let workload = ctx.workload();
let db = ctx.database();

DB_METRICS
.wasm_abi_call_duration_sec
.with_label_values(&workload, &db, &self.reducer_name, &call)
.with_label_values(&db, &self.reducer_name, &call)
.start_timer()
}

Expand Down