Skip to content

Commit

Permalink
docs: improve some comments and remove infallible condition from metr…
Browse files Browse the repository at this point in the history
…ics (#2773)
  • Loading branch information
rumenov authored Nov 22, 2024
1 parent a0be7ba commit b2a094f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions rs/p2p/quic_transport/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub(crate) const CONNECTION_RESULT_SUCCESS_LABEL: &str = "success";
pub(crate) const CONNECTION_RESULT_FAILED_LABEL: &str = "failed";
pub(crate) const ERROR_TYPE_APP: &str = "app";
pub(crate) const INFALIBBLE: &str = "infallible";
const ERROR_CLOSED_STREAM: &str = "closed_stream";
const ERROR_RESET_STREAM: &str = "reset_stream";
const ERROR_STOPPED_STREAM: &str = "stopped_stream";
const ERROR_APP_CLOSED_CONN: &str = "app_closed_conn";
Expand Down Expand Up @@ -205,15 +204,17 @@ impl QuicTransportMetrics {

pub fn observe_conn_error(err: &ConnectionError, op: &str, counter: &IntCounterVec) {
match err {
// This can occur during a topology change or when the connection manager attempts to replace an old, broken connection with a new one.
ConnectionError::LocallyClosed => counter
.with_label_values(&[op, ERROR_LOCALLY_CLOSED_CONN])
.inc(),
// This can occur during a topology change or when the connection manager attempts to replace an old, broken connection with a new one.
ConnectionError::ApplicationClosed(_) => counter
.with_label_values(&[op, ERROR_APP_CLOSED_CONN])
.inc(),
// Can happen if peer crashes or there are connectivity problems.
// This can occur if the peer crashes or experiences connectivity issues.
ConnectionError::TimedOut => counter.with_label_values(&[op, ERROR_TIMED_OUT_CONN]).inc(),
// A connection was closed by the QUIC protocol.
// A connection was closed by the QUIC protocol. Overall should be infallible.
_ => counter
.with_label_values(&[op, ERROR_QUIC_CLOSED_CONN])
.inc(),
Expand All @@ -225,9 +226,11 @@ pub fn observe_write_error(err: &WriteError, op: &str, counter: &IntCounterVec)
// This should be infallible. The peer will never stop a stream, it can only reset it.
WriteError::Stopped(_) => counter.with_label_values(&[op, ERROR_STOPPED_STREAM]).inc(),
WriteError::ConnectionLost(conn_err) => observe_conn_error(conn_err, op, counter),
// This should be infallible
WriteError::ClosedStream => counter.with_label_values(&[op, ERROR_CLOSED_STREAM]).inc(),
_ => counter.with_label_values(&[op, INFALIBBLE]).inc(),
// If any of the following errors occur it means that we have a bug in the protocol implementation or
// there is malicious peer on the other side.
WriteError::ClosedStream | WriteError::ZeroRttRejected => {
counter.with_label_values(&[op, INFALIBBLE]).inc()
}
}
}

Expand Down

0 comments on commit b2a094f

Please sign in to comment.