Skip to content

Commit 4fc095c

Browse files
Change spacetime_worker_wasm_instance_errors_total metric's labels (#3614)
# Description of Changes There are two purposes for introducing the changes in this commit: 1. Decrease the cardinality of the metric, as the caller id and connection id cwould result in way too combiations 2. Add a database_identity label, which is much more useful for the metric # API and ABI breaking changes I'm honestly not sure if metrics labels change is an API breaking change, I suppose not? For what it's worth, I don't think that anyone was relying on the labels I've removed. # Expected complexity level and risk 1 # Testing - [x] I've tested the change locally Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
1 parent 1b87bac commit 4fc095c

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
@@ -635,12 +635,7 @@ impl InstanceCommon {
635635

636636
WORKER_METRICS
637637
.wasm_instance_errors
638-
.with_label_values(
639-
&caller_identity,
640-
&self.info.module_hash,
641-
&caller_connection_id,
642-
procedure_name,
643-
)
638+
.with_label_values(&self.info.database_identity, &self.info.module_hash, procedure_name)
644639
.inc();
645640

646641
// TODO(procedure-energy):
@@ -747,12 +742,7 @@ impl InstanceCommon {
747742
Err(ExecutionError::Recoverable(err) | ExecutionError::Trap(err)) => {
748743
inst.log_traceback("reducer", reducer_name, &err);
749744

750-
self.handle_outer_error(
751-
&result.stats.energy,
752-
&caller_identity,
753-
&Some(caller_connection_id),
754-
reducer_name,
755-
)
745+
self.handle_outer_error(&result.stats.energy, reducer_name)
756746
}
757747
Err(ExecutionError::User(err)) => {
758748
log_reducer_error(inst.replica_ctx(), timestamp, reducer_name, &err);
@@ -827,21 +817,10 @@ impl InstanceCommon {
827817
(res, trapped)
828818
}
829819

830-
fn handle_outer_error(
831-
&mut self,
832-
energy: &EnergyStats,
833-
caller_identity: &Identity,
834-
caller_connection_id: &Option<ConnectionId>,
835-
reducer_name: &str,
836-
) -> EventStatus {
820+
fn handle_outer_error(&mut self, energy: &EnergyStats, reducer_name: &str) -> EventStatus {
837821
WORKER_METRICS
838822
.wasm_instance_errors
839-
.with_label_values(
840-
caller_identity,
841-
&self.info.module_hash,
842-
&caller_connection_id.unwrap_or(ConnectionId::ZERO),
843-
reducer_name,
844-
)
823+
.with_label_values(&self.info.database_identity, &self.info.module_hash, reducer_name)
845824
.inc();
846825

847826
if energy.remaining.get() == 0 {
@@ -964,14 +943,12 @@ impl InstanceCommon {
964943
let outcome = match (result.call_result, sender) {
965944
(Err(ExecutionError::Recoverable(err) | ExecutionError::Trap(err)), _) => {
966945
inst.log_traceback("view", &view_name, &err);
967-
self.handle_outer_error(&result.stats.energy, &caller, &None, &view_name)
968-
.into()
946+
self.handle_outer_error(&result.stats.energy, &view_name).into()
969947
}
970948
// TODO: maybe do something else with user errors?
971949
(Err(ExecutionError::User(err)), _) => {
972950
inst.log_traceback("view", &view_name, &anyhow::anyhow!(err));
973-
self.handle_outer_error(&result.stats.energy, &caller, &None, &view_name)
974-
.into()
951+
self.handle_outer_error(&result.stats.energy, &view_name).into()
975952
}
976953
// Materialize anonymous view
977954
(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)