Add connection-level timing metrics and key update tracking to Stats#2416
Open
devin-cog wants to merge 1 commit into
Open
Add connection-level timing metrics and key update tracking to Stats#2416devin-cog wants to merge 1 commit into
devin-cog wants to merge 1 commit into
Conversation
Add new fields to the public Stats struct for production observability: - handshake_duration: time from connection creation to handshake completion - key_update_count: number of 1-RTT key updates - peer_max_idle_timeout: peer's max idle timeout from transport params - connection_duration: wall-clock time since connection creation Implementation details: - Track created_at (Instant) and handshake_completed_at (Option<Instant>) on Connection, initialized in with_tls() and set on handshake completion - Track key_update_count on Connection, incremented when a peer-initiated key update is verified - Populate new Stats fields in stats() method - Update Debug impl for Stats to include new fields - Expose via FFI: new fields in the C Stats struct plus standalone query functions (quiche_conn_stats_handshake_duration_ms, etc.) - Add unit tests verifying pre/post handshake behavior Co-Authored-By: Staging-Devin AI <166158716+staging-devin-ai-integration[bot]@users.noreply.github.com>
|
|
||
| if let Some(hs) = self.handshake_duration { | ||
| write!(f, " handshake_duration={:?}", hs)?; | ||
| } |
Contributor
There was a problem hiding this comment.
Also add key_update_count ?
| } else { | ||
| None | ||
| }, | ||
| connection_duration: self.created_at.elapsed(), |
Contributor
There was a problem hiding this comment.
I would have considered providing the creation time since that's also an important piece of info when logging info on a connection. The caller can compute duration on it's own based on that.
I could see there being some challenges with logging wanting to use SystemTime instead of Monotonic time.
| tx_buffered_state: self.tx_buffered_state, | ||
| handshake_duration: self | ||
| .handshake_completed_at | ||
| .map(|completed| completed.duration_since(self.created_at)), |
Contributor
There was a problem hiding this comment.
Should the connection store the handshake_duration instead of handshake_completed_at?
|
|
||
| /// Returns the handshake duration in milliseconds, or -1 if the | ||
| /// handshake has not yet completed. | ||
| #[no_mangle] |
Contributor
There was a problem hiding this comment.
Are the extra ffi functions below needed despite the data being available via quiche_conn_stats above?
Contributor
|
Thanks for the stats improvements. See comments above. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add new fields to the public
Statsstruct for production observability:handshake_duration: Option<Duration>— time from connection creation to handshake completion,Noneif handshake hasn't completedkey_update_count: u64— number of 1-RTT key updatespeer_max_idle_timeout: Option<Duration>— the peer's max idle timeout from transport paramsconnection_duration: Duration— wall-clock time since connection creationImplementation details
created_at: Instantandhandshake_completed_at: Option<Instant>onConnection, initialized inwith_tls()and set when handshake completeskey_update_count: u64onConnection, incremented when a peer-initiated key update is verifiedStatsfields instats()methodDebugimpl forStatsto include new fieldsStatsstruct plus standalone query functions (quiche_conn_stats_handshake_duration_ms,quiche_conn_stats_key_update_count,quiche_conn_stats_peer_max_idle_timeout_ms,quiche_conn_stats_connection_duration_ms)Verification
cargo buildsucceedscargo +nightly fmt -- --checkcleancargo clippy --features=boringssl-vendored --workspace -- -D warningscleanReview & Testing Checklist for Human
handshake_completed_atis set at the right place — it's set right afterself.handshake.is_completed()returns truekey_update_countincrement location — placed after key update is verified (after successful decryption with new keys), per RFC 9001i64with-1sentinel for optional durations; confirm this matches downstream C consumer expectationsNotes
integration_tests::test_so_mark_receive_datain tokio-quiche, which requires special socket permissions and is unrelated to this changepeer_max_idle_timeoutreturnsNonewhen the peer's transport params haven't been parsed yet or whenmax_idle_timeoutis 0 (which per RFC 9000 means no timeout)