Skip to content

Commit c5c372e

Browse files
committed
Change spacetime_worker_wasm_instance_errors_total metric's labels
There are two purpose for introducing the changes in this commit: 1. Decrease the cardinality of the metric, as caller id and connection id combination would result in way too many combinations 2. Add a database_identity label, which is much more useful for the metric
1 parent 3ea5fde commit c5c372e

File tree

2 files changed

+8
-31
lines changed

2 files changed

+8
-31
lines changed

crates/core/src/host/wasm_common/module_host_actor.rs

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -575,12 +575,7 @@ impl InstanceCommon {
575575

576576
WORKER_METRICS
577577
.wasm_instance_errors
578-
.with_label_values(
579-
&caller_identity,
580-
&self.info.module_hash,
581-
&caller_connection_id,
582-
procedure_name,
583-
)
578+
.with_label_values(&self.info.database_identity, &self.info.module_hash, procedure_name)
584579
.inc();
585580

586581
// TODO(procedure-energy):
@@ -686,12 +681,7 @@ impl InstanceCommon {
686681
Err(ExecutionError::Recoverable(err) | ExecutionError::Trap(err)) => {
687682
inst.log_traceback("reducer", reducer_name, &err);
688683

689-
self.handle_outer_error(
690-
&result.stats.energy,
691-
&caller_identity,
692-
&Some(caller_connection_id),
693-
reducer_name,
694-
)
684+
self.handle_outer_error(&result.stats.energy, reducer_name)
695685
}
696686
Err(ExecutionError::User(err)) => {
697687
log_reducer_error(inst.replica_ctx(), timestamp, reducer_name, &err);
@@ -766,21 +756,10 @@ impl InstanceCommon {
766756
(res, trapped)
767757
}
768758

769-
fn handle_outer_error(
770-
&mut self,
771-
energy: &EnergyStats,
772-
caller_identity: &Identity,
773-
caller_connection_id: &Option<ConnectionId>,
774-
reducer_name: &str,
775-
) -> EventStatus {
759+
fn handle_outer_error(&mut self, energy: &EnergyStats, reducer_name: &str) -> EventStatus {
776760
WORKER_METRICS
777761
.wasm_instance_errors
778-
.with_label_values(
779-
caller_identity,
780-
&self.info.module_hash,
781-
&caller_connection_id.unwrap_or(ConnectionId::ZERO),
782-
reducer_name,
783-
)
762+
.with_label_values(&self.info.database_identity, &self.info.module_hash, reducer_name)
784763
.inc();
785764

786765
if energy.remaining.get() == 0 {
@@ -903,14 +882,12 @@ impl InstanceCommon {
903882
let outcome = match (result.call_result, sender) {
904883
(Err(ExecutionError::Recoverable(err) | ExecutionError::Trap(err)), _) => {
905884
inst.log_traceback("view", &view_name, &err);
906-
self.handle_outer_error(&result.stats.energy, &caller, &None, &view_name)
907-
.into()
885+
self.handle_outer_error(&result.stats.energy, &view_name).into()
908886
}
909887
// TODO: maybe do something else with user errors?
910888
(Err(ExecutionError::User(err)), _) => {
911889
inst.log_traceback("view", &view_name, &anyhow::anyhow!(err));
912-
self.handle_outer_error(&result.stats.energy, &caller, &None, &view_name)
913-
.into()
890+
self.handle_outer_error(&result.stats.energy, &view_name).into()
914891
}
915892
// Materialize anonymous view
916893
(Ok(bytes), None) => {

crates/core/src/worker_metrics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::messages::control_db::HostType;
33
use once_cell::sync::Lazy;
44
use prometheus::{GaugeVec, HistogramVec, IntCounterVec, IntGaugeVec};
55
use spacetimedb_datastore::execution_context::WorkloadType;
6-
use spacetimedb_lib::{ConnectionId, Identity};
6+
use spacetimedb_lib::Identity;
77
use spacetimedb_metrics::metrics_group;
88
use spacetimedb_sats::memory_usage::MemoryUsage;
99
use spacetimedb_table::page_pool::PagePool;
@@ -243,7 +243,7 @@ metrics_group!(
243243

244244
#[name = spacetime_worker_wasm_instance_errors_total]
245245
#[help = "The number of fatal WASM instance errors, such as reducer panics."]
246-
#[labels(caller_identity: Identity, module_hash: Hash, caller_connection_id: ConnectionId, reducer_symbol: str)]
246+
#[labels(database_identity: Identity, module_hash: Hash, reducer_symbol: str)]
247247
pub wasm_instance_errors: IntCounterVec,
248248

249249
#[name = spacetime_worker_wasm_memory_bytes]

0 commit comments

Comments
 (0)