Skip to content

Commit 53e776f

Browse files
feat(748): Add compile time feature flag for table metrics
Closes #748. This patch adds a temporary feature flag for enabling table metrics. Table metrics are potentially recorded many times within a transaction. This recording is synchronous and therefore can have a noticable impact on latency. This new flag will be enabled by default. With it, table metrics will be recorded; without it, they won't. Note this flag is temporary. It will be removed once metrics are recorded async.
1 parent 602f1ba commit 53e776f

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
sudo chmod 777 /stdb
4646
4747
- name: Run cargo test
48-
run: cargo test --all --features odb_rocksdb,odb_sled
48+
run: cargo test --all --features odb_rocksdb,odb_sled,metrics
4949

5050
lints:
5151
name: Lints
@@ -61,7 +61,7 @@ jobs:
6161
run: cargo fmt --all -- --check
6262

6363
- name: Run cargo clippy
64-
run: cargo clippy --all --tests --features odb_rocksdb,odb_sled -- -D warnings
64+
run: cargo clippy --all --tests --features odb_rocksdb,odb_sled,metrics -- -D warnings
6565

6666
wasm_bindings:
6767
name: Build and test wasm bindings

crates/core/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ wasmtime.workspace = true
9393
rocksdb = {workspace = true, optional = true}
9494

9595
[features]
96+
# Optional metrics collected by spacetimedb.
97+
metrics = []
9698
# Optional storage engines.
9799
odb_rocksdb = ["dep:rocksdb"]
98100
odb_sled = []
99-
default = ["odb_sled"]
101+
default = ["odb_sled", "metrics"]
100102

101103
[dev-dependencies]
102104
spacetimedb-lib = { path = "../lib", features = ["proptest"] }

crates/core/src/db/datastore/locking_tx_datastore/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,7 @@ pub struct Iter<'a> {
19781978
num_committed_rows_fetched: u64,
19791979
}
19801980

1981+
#[cfg(feature = "metrics")]
19811982
impl Drop for Iter<'_> {
19821983
fn drop(&mut self) {
19831984
DB_METRICS
@@ -2111,6 +2112,7 @@ pub struct IndexSeekIterMutTxId<'a> {
21112112
num_committed_rows_fetched: u64,
21122113
}
21132114

2115+
#[cfg(feature = "metrics")]
21142116
impl Drop for IndexSeekIterMutTxId<'_> {
21152117
fn drop(&mut self) {
21162118
let table_name = self
@@ -2195,6 +2197,7 @@ pub struct CommittedIndexIter<'a> {
21952197
num_committed_rows_fetched: u64,
21962198
}
21972199

2200+
#[cfg(feature = "metrics")]
21982201
impl Drop for CommittedIndexIter<'_> {
21992202
fn drop(&mut self) {
22002203
let table_name = self

0 commit comments

Comments
 (0)