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
4 changes: 4 additions & 0 deletions crates/core/src/db/db_metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,7 @@ metrics_group!(

pub static MAX_TX_CPU_TIME: Lazy<Mutex<HashMap<u64, f64>>> = Lazy::new(|| Mutex::new(HashMap::new()));
pub static DB_METRICS: Lazy<DbMetrics> = Lazy::new(DbMetrics::new);

pub fn reset_counters() {
MAX_TX_CPU_TIME.lock().unwrap().clear();
}
5 changes: 5 additions & 0 deletions crates/core/src/worker_metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,8 @@ metrics_group!(
pub static MAX_QUEUE_LEN: Lazy<Mutex<HashMap<Address, i64>>> = Lazy::new(|| Mutex::new(HashMap::new()));
pub static MAX_REDUCER_DELAY: Lazy<Mutex<HashMap<u64, f64>>> = Lazy::new(|| Mutex::new(HashMap::new()));
pub static WORKER_METRICS: Lazy<WorkerMetrics> = Lazy::new(WorkerMetrics::new);

pub fn reset_counters() {
MAX_QUEUE_LEN.lock().unwrap().clear();
MAX_REDUCER_DELAY.lock().unwrap().clear();
}
14 changes: 5 additions & 9 deletions crates/standalone/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use spacetimedb::client::ClientActorIndex;
use spacetimedb::control_db::{self, ControlDb};
use spacetimedb::database_instance_context::DatabaseInstanceContext;
use spacetimedb::database_instance_context_controller::DatabaseInstanceContextController;
use spacetimedb::db::db_metrics::MAX_TX_CPU_TIME;
use spacetimedb::db::db_metrics;
use spacetimedb::db::{db_metrics::DB_METRICS, Config};
use spacetimedb::execution_context::ExecutionContext;
use spacetimedb::host::EnergyQuanta;
Expand All @@ -31,8 +31,8 @@ use spacetimedb::messages::control_db::{Database, DatabaseInstance, HostType, Id
use spacetimedb::module_host_context::ModuleHostContext;
use spacetimedb::object_db::ObjectDb;
use spacetimedb::sendgrid_controller::SendGridController;
use spacetimedb::stdb_path;
use spacetimedb::worker_metrics::{MAX_QUEUE_LEN, MAX_REDUCER_DELAY, WORKER_METRICS};
use spacetimedb::worker_metrics::WORKER_METRICS;
use spacetimedb::{stdb_path, worker_metrics};
use spacetimedb_lib::name::{DomainName, InsertDomainResult, RegisterTldResult, Tld};
use spacetimedb_lib::recovery::RecoveryCode;
use std::fs::File;
Expand Down Expand Up @@ -166,12 +166,8 @@ fn get_key_path(env: &str) -> Option<PathBuf> {
impl spacetimedb_client_api::NodeDelegate for StandaloneEnv {
fn gather_metrics(&self) -> Vec<prometheus::proto::MetricFamily> {
defer_on_success! {
// Reset max transaction cpu time metric
MAX_TX_CPU_TIME.lock().unwrap().clear();
// Reset max queue length metric
MAX_QUEUE_LEN.lock().unwrap().clear();
// Reset max reducer delay metric
MAX_REDUCER_DELAY.lock().unwrap().clear();
db_metrics::reset_counters();
worker_metrics::reset_counters();
}
// Note, we update certain metrics such as disk usage on demand.
self.db_inst_ctx_controller.update_metrics();
Expand Down