Skip to content

Commit a76b726

Browse files
Track disconnects initiated by the client
1 parent 67703b1 commit a76b726

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

crates/client-api/src/routes/subscribe.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,15 @@ async fn ws_client_actor_inner(
431431

432432
// if this is the closed-by-them case, let the ClientConnectionSenders know now.
433433
sendrx.close();
434-
closed = true;
435434
log::trace!("Close frame {:?}", close_frame);
435+
if !closed {
436+
// This is the client telling us they want to close.
437+
WORKER_METRICS
438+
.ws_clients_closed_connection
439+
.with_label_values(&addr)
440+
.inc();
441+
}
442+
closed = true;
436443
}
437444
}
438445
}

crates/core/src/worker_metrics/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ metrics_group!(
2121
pub ws_clients_spawned: IntGaugeVec,
2222

2323
#[name = spacetime_worker_ws_clients_aborted]
24-
#[help = "Number of ws client connections aborted"]
24+
#[help = "Number of ws client connections aborted by either the server or the client"]
2525
#[labels(database_identity: Identity)]
2626
pub ws_clients_aborted: IntGaugeVec,
2727

28+
#[name = spacetime_worker_ws_clients_closed_connection]
29+
#[help = "Number of ws connections closed by the client"]
30+
#[labels(database_identity: Identity)]
31+
pub ws_clients_closed_connection: IntGaugeVec,
32+
2833
#[name = spacetime_websocket_requests_total]
2934
#[help = "The cumulative number of websocket request messages"]
3035
#[labels(database_identity: Identity, protocol: str)]

0 commit comments

Comments
 (0)