feat: add runtime-gated QUIC connection diagnostic logging#9
feat: add runtime-gated QUIC connection diagnostic logging#9iamvamsikrishnad wants to merge 3 commits intomicrosoft:mainfrom
Conversation
Add detailed tracing-based logging across the QUIC connection lifecycle to help diagnose connection drops. All logging is gated behind a runtime toggle (snocat::quic_logging::enable()) so library consumers opt in explicitly with zero overhead when disabled. Covered scenarios: - Connection creation with tunnel ID, remote address, and side - Connection error conversion (version mismatch, transport error, peer close, application close, stateless reset, idle timeout, local close) with distinct messages and structured fields - Incoming stream acceptance failures (accept_bi) per error variant - Outgoing stream open failures (open_bi) per error variant - Tunnel close with reason - Listen endpoint bind, incoming handshake, and termination - Server-side handshake failures (previously silently swallowed) - Client-side connection initiation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@iamvamsikrishnad please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
1 similar comment
|
@iamvamsikrishnad please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
Adds runtime-gated tracing diagnostics for QUIC connection lifecycle events in the snocat library (plus a couple of CLI-side connection/handshake logs) to improve visibility into connection drops and failures.
Changes:
- Introduces
snocat::quic_loggingwith a globalAtomicBoolruntime toggle (enable/disable/is_enabled). - Adds toggle-gated QUIC lifecycle logs in the library (endpoint bind/accept lifecycle, tunnel creation/close, stream open/accept failures, connection error conversion).
- Replaces a swallowed handshake failure (
.ok()) with explicit logging insnocat-cli, and logs client connection initiation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| snocat/src/quic_logging.rs | New runtime toggle module for enabling/disabling QUIC diagnostic logs. |
| snocat/src/lib.rs | Exposes the new quic_logging module publicly. |
| snocat/src/common/tunnel_source/mod.rs | Adds gated endpoint bind/accept/termination tracing. |
| snocat/src/common/protocol/tunnel/quinn_tunnel.rs | Adds gated tunnel/stream lifecycle tracing and detailed ConnectionError logging. |
| snocat-cli/src/server.rs | Logs successful/failed incoming QUIC handshakes (previously swallowed). |
| snocat-cli/src/client.rs | Logs QUIC client connection initiation. |
Comments suppressed due to low confidence (1)
snocat/src/common/protocol/tunnel/quinn_tunnel.rs:169
- In the incoming stream
inspect_errhandler, the close reason is always stored asTunnelError::ConnectionClosedregardless of the actualtunnel_error(ApplicationClosed/TimedOut/TransportError/LocallyClosed). This can makeon_closed()and other close-reason reporting inaccurate; store the actual error (clone oftunnel_error) instead of hard-coding ConnectionClosed.
let close_reason = TunnelCloseReason::Error(TunnelError::ConnectionClosed);
{
let close_reason_store = &close_reason_store;
close_reason_store.store(Arc::new(close_reason));
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if logging { | ||
| tracing::warn!( | ||
| error_code = %e.code, | ||
| reason = %e.reason, |
There was a problem hiding this comment.
reason = %e.reason likely won’t compile because quinn::TransportError::reason is a byte buffer type (e.g., bytes::Bytes) that does not implement Display. Use ?e.reason (Debug) or convert to a lossy/hex string before emitting it as a % field.
| reason = %e.reason, | |
| reason = %String::from_utf8_lossy(&e.reason), |
| quinn::ConnectionError::TransportError(ref e) => { | ||
| if logging { | ||
| tracing::warn!( | ||
| error_code = %e.code, | ||
| reason = %e.reason, | ||
| "QUIC connection dropped: transport error - {}", | ||
| e | ||
| ); | ||
| } | ||
| Self::TransportError |
There was a problem hiding this comment.
PR description says transport errors should be logged at error severity, but quinn::ConnectionError::TransportError is currently emitted with tracing::warn!. Either bump this to error! (to match the stated severity and the other TransportError logs in this file) or update the PR description to reflect the intended level.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Adds detailed tracing-based logging across the QUIC connection lifecycle to help diagnose connection drops. All logging is gated behind a runtime toggle so library consumers opt in explicitly.
Motivation
QUIC connections can drop for many reasons (idle timeouts, transport errors, stateless resets, version mismatches, peer closures) but the library previously provided no diagnostic visibility into these events. Handshake failures were silently swallowed with .ok().
Changes
New module: \snocat::quic_logging\
Runtime toggle backed by \AtomicBool\ — zero overhead when disabled:
\
ust
snocat::quic_logging::enable(); // opt in
snocat::quic_logging::disable(); // opt out
snocat::quic_logging::is_enabled(); // check
\\
Logging coverage (all gated behind the toggle)
Severity levels