diff --git a/crates/core/src/client/client_connection.rs b/crates/core/src/client/client_connection.rs index dd8b50633b..60745ff7bf 100644 --- a/crates/core/src/client/client_connection.rs +++ b/crates/core/src/client/client_connection.rs @@ -113,6 +113,8 @@ impl ClientConnection { // Buffer up to 64 client messages let (sendtx, sendrx) = mpsc::channel::(64); + let db = module.info().address; + let sender = ClientConnectionSender { id, protocol, sendtx }; let this = Self { sender, @@ -121,7 +123,7 @@ impl ClientConnection { }; let actor_fut = actor(this.clone(), sendrx); - let gauge_guard = WORKER_METRICS.connected_clients.inc_scope(); + let gauge_guard = WORKER_METRICS.connected_clients.with_label_values(&db).inc_scope(); tokio::spawn(actor_fut.map(|()| drop(gauge_guard))); Ok(this) diff --git a/crates/core/src/worker_metrics/mod.rs b/crates/core/src/worker_metrics/mod.rs index 560abc8339..9751d52f61 100644 --- a/crates/core/src/worker_metrics/mod.rs +++ b/crates/core/src/worker_metrics/mod.rs @@ -1,13 +1,14 @@ use crate::util::typed_prometheus::metrics_group; use once_cell::sync::Lazy; -use prometheus::{Gauge, GaugeVec, HistogramVec, IntCounterVec, IntGauge, IntGaugeVec}; +use prometheus::{Gauge, GaugeVec, HistogramVec, IntCounterVec, IntGaugeVec}; use spacetimedb_lib::{Address, Hash, Identity}; metrics_group!( pub struct WorkerMetrics { #[name = spacetime_worker_connected_clients] #[help = "Number of clients connected to the worker."] - pub connected_clients: IntGauge, + #[labels(database_address: Address)] + pub connected_clients: IntGaugeVec, #[name = spacetime_websocket_requests] #[help = "Number of websocket request messages"]