mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-24 17:49:07 -05:00
improvement: provide reason for abort in prometheus metric
This commit is contained in:
parent
3fcaf97a15
commit
214f152c5d
|
@ -358,7 +358,7 @@ ON CONFLICT (id) DO NOTHING"#,
|
||||||
if last_successful_send + abort_cutoff < Instant::now() {
|
if last_successful_send + abort_cutoff < Instant::now() {
|
||||||
// the queue has been full for too long, abort
|
// the queue has been full for too long, abort
|
||||||
info!("aborting database query due to slow client");
|
info!("aborting database query due to slow client");
|
||||||
metrics.query_aborts.inc();
|
metrics.query_aborts.with_label_values(&["slowclient"]).inc();
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
// give the queue a chance to clear before trying again
|
// give the queue a chance to clear before trying again
|
||||||
|
|
|
@ -323,6 +323,7 @@ impl NostrRepo for SqliteRepo {
|
||||||
"shedding DB query load queued for {:?} (cid: {}, sub: {:?})",
|
"shedding DB query load queued for {:?} (cid: {}, sub: {:?})",
|
||||||
db_queue_time, client_id, sub.id
|
db_queue_time, client_id, sub.id
|
||||||
);
|
);
|
||||||
|
metrics.query_aborts.with_label_values(&["loadshed"]).inc();
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
// otherwise, report queuing time if it is slow
|
// otherwise, report queuing time if it is slow
|
||||||
|
@ -383,7 +384,7 @@ impl NostrRepo for SqliteRepo {
|
||||||
if self.checkpoint_in_progress.try_lock().is_err() {
|
if self.checkpoint_in_progress.try_lock().is_err() {
|
||||||
// lock was held, abort this query
|
// lock was held, abort this query
|
||||||
debug!("query aborted due to checkpoint (cid: {}, sub: {:?})", client_id, sub.id);
|
debug!("query aborted due to checkpoint (cid: {}, sub: {:?})", client_id, sub.id);
|
||||||
metrics.query_aborts.inc();
|
metrics.query_aborts.with_label_values(&["checkpoint"]).inc();
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,7 +408,7 @@ impl NostrRepo for SqliteRepo {
|
||||||
// the queue has been full for too long, abort
|
// the queue has been full for too long, abort
|
||||||
info!("aborting database query due to slow client (cid: {}, sub: {:?})",
|
info!("aborting database query due to slow client (cid: {}, sub: {:?})",
|
||||||
client_id, sub.id);
|
client_id, sub.id);
|
||||||
metrics.query_aborts.inc();
|
metrics.query_aborts.with_label_values(&["slowclient"]).inc();
|
||||||
let ok: Result<()> = Ok(());
|
let ok: Result<()> = Ok(());
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
@ -415,7 +416,7 @@ impl NostrRepo for SqliteRepo {
|
||||||
if self.checkpoint_in_progress.try_lock().is_err() {
|
if self.checkpoint_in_progress.try_lock().is_err() {
|
||||||
// lock was held, abort this query
|
// lock was held, abort this query
|
||||||
debug!("query aborted due to checkpoint (cid: {}, sub: {:?})", client_id, sub.id);
|
debug!("query aborted due to checkpoint (cid: {}, sub: {:?})", client_id, sub.id);
|
||||||
metrics.query_aborts.inc();
|
metrics.query_aborts.with_label_values(&["checkpoint"]).inc();
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
// give the queue a chance to clear before trying again
|
// give the queue a chance to clear before trying again
|
||||||
|
|
|
@ -244,10 +244,10 @@ fn create_metrics() -> (Registry, NostrMetrics) {
|
||||||
"nostr_connections_total",
|
"nostr_connections_total",
|
||||||
"New connections",
|
"New connections",
|
||||||
)).unwrap();
|
)).unwrap();
|
||||||
let query_aborts = IntCounter::with_opts(Opts::new(
|
let query_aborts = IntCounterVec::new(
|
||||||
"nostr_query_abort_total",
|
Opts::new("nostr_query_abort_total", "Aborted queries"),
|
||||||
"Aborted queries",
|
vec!["reason"].as_slice(),
|
||||||
)).unwrap();
|
).unwrap();
|
||||||
let cmd_req = IntCounter::with_opts(Opts::new(
|
let cmd_req = IntCounter::with_opts(Opts::new(
|
||||||
"nostr_cmd_req_total",
|
"nostr_cmd_req_total",
|
||||||
"REQ commands",
|
"REQ commands",
|
||||||
|
@ -834,7 +834,7 @@ pub struct NostrMetrics {
|
||||||
pub sent_events: IntCounterVec, // count of events sent to clients
|
pub sent_events: IntCounterVec, // count of events sent to clients
|
||||||
pub connections: IntCounter, // count of websocket connections
|
pub connections: IntCounter, // count of websocket connections
|
||||||
pub disconnects: IntCounterVec, // client disconnects
|
pub disconnects: IntCounterVec, // client disconnects
|
||||||
pub query_aborts: IntCounter, // count of queries aborted by server
|
pub query_aborts: IntCounterVec, // count of queries aborted by server
|
||||||
pub cmd_req: IntCounter, // count of REQ commands received
|
pub cmd_req: IntCounter, // count of REQ commands received
|
||||||
pub cmd_event: IntCounter, // count of EVENT commands received
|
pub cmd_event: IntCounter, // count of EVENT commands received
|
||||||
pub cmd_close: IntCounter, // count of CLOSE commands received
|
pub cmd_close: IntCounter, // count of CLOSE commands received
|
||||||
|
|
Loading…
Reference in New Issue
Block a user