Skip to content

Commit 3fc61bc

Browse files
authored
Add counters for client connections spawned and aborted. (#2741)
1 parent 0829f7d commit 3fc61bc

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

crates/core/src/client/client_connection.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ impl ClientConnection {
209209
let Ok(fut) = fut_rx.await else { return };
210210

211211
let _gauge_guard = WORKER_METRICS.connected_clients.with_label_values(&db).inc_scope();
212+
WORKER_METRICS.ws_clients_spawned.with_label_values(&db).inc();
213+
scopeguard::defer!(WORKER_METRICS.ws_clients_aborted.with_label_values(&db).inc());
212214

213215
fut.await
214216
})

crates/core/src/worker_metrics/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ metrics_group!(
1515
#[labels(database_identity: Identity)]
1616
pub connected_clients: IntGaugeVec,
1717

18+
#[name = spacetime_worker_ws_clients_spawned]
19+
#[help = "Number of new ws client connections spawned. Counted after any on_connect reducers are run."]
20+
#[labels(database_identity: Identity)]
21+
pub ws_clients_spawned: IntGaugeVec,
22+
23+
#[name = spacetime_worker_ws_clients_aborted]
24+
#[help = "Number of ws client connections aborted"]
25+
#[labels(database_identity: Identity)]
26+
pub ws_clients_aborted: IntGaugeVec,
27+
1828
#[name = spacetime_websocket_requests_total]
1929
#[help = "The cumulative number of websocket request messages"]
2030
#[labels(replica_id: u64, protocol: str)]

0 commit comments

Comments
 (0)