Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improve some comments and remove infallible condition from metrics #2773

Merged
merged 4 commits into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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