Skip to content

Commit

Permalink
feat(s2n-quic-dc): metric for forward gaps in key ID tracking (#2382)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum authored Nov 20, 2024
1 parent 6c3874e commit c075830
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 120 deletions.
10 changes: 9 additions & 1 deletion dc/s2n-quic-dc/events/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,17 @@ struct KeyAccepted<'a> {

key_id: u64,

/// How far away this credential is from the leading edge of key IDs.
/// How far away this credential is from the leading edge of key IDs (after updating the edge).
///
/// Zero if this shifted us forward.
#[measure("gap")]
gap: u64,

/// How far away this credential is from the leading edge of key IDs (before updating the edge).
///
/// Zero if this didn't change the leading edge.
#[measure("forward_shift")]
forward_shift: u64,
}

#[event("path_secret_map:replay_definitely_detected")]
Expand Down
22 changes: 19 additions & 3 deletions dc/s2n-quic-dc/src/event/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,14 @@ pub mod api {
pub struct KeyAccepted<'a> {
pub credential_id: &'a [u8],
pub key_id: u64,
#[doc = " How far away this credential is from the leading edge of key IDs."]
#[doc = " How far away this credential is from the leading edge of key IDs (after updating the edge)."]
#[doc = ""]
#[doc = " Zero if this shifted us forward."]
pub gap: u64,
#[doc = " How far away this credential is from the leading edge of key IDs (before updating the edge)."]
#[doc = ""]
#[doc = " Zero if this didn't change the leading edge."]
pub forward_shift: u64,
}
#[cfg(any(test, feature = "testing"))]
impl<'a> crate::event::snapshot::Fmt for KeyAccepted<'a> {
Expand All @@ -902,6 +908,7 @@ pub mod api {
fmt.field("credential_id", &"[HIDDEN]");
fmt.field("key_id", &self.key_id);
fmt.field("gap", &self.gap);
fmt.field("forward_shift", &self.forward_shift);
fmt.finish()
}
}
Expand Down Expand Up @@ -1618,8 +1625,9 @@ pub mod tracing {
credential_id,
key_id,
gap,
forward_shift,
} = event;
tracing :: event ! (target : "key_accepted" , parent : parent , tracing :: Level :: DEBUG , credential_id = tracing :: field :: debug (credential_id) , key_id = tracing :: field :: debug (key_id) , gap = tracing :: field :: debug (gap));
tracing :: event ! (target : "key_accepted" , parent : parent , tracing :: Level :: DEBUG , credential_id = tracing :: field :: debug (credential_id) , key_id = tracing :: field :: debug (key_id) , gap = tracing :: field :: debug (gap) , forward_shift = tracing :: field :: debug (forward_shift));
}
#[inline]
fn on_replay_definitely_detected(
Expand Down Expand Up @@ -2626,8 +2634,14 @@ pub mod builder {
pub struct KeyAccepted<'a> {
pub credential_id: &'a [u8],
pub key_id: u64,
#[doc = " How far away this credential is from the leading edge of key IDs."]
#[doc = " How far away this credential is from the leading edge of key IDs (after updating the edge)."]
#[doc = ""]
#[doc = " Zero if this shifted us forward."]
pub gap: u64,
#[doc = " How far away this credential is from the leading edge of key IDs (before updating the edge)."]
#[doc = ""]
#[doc = " Zero if this didn't change the leading edge."]
pub forward_shift: u64,
}
impl<'a> IntoEvent<api::KeyAccepted<'a>> for KeyAccepted<'a> {
#[inline]
Expand All @@ -2636,11 +2650,13 @@ pub mod builder {
credential_id,
key_id,
gap,
forward_shift,
} = self;
api::KeyAccepted {
credential_id: credential_id.into_event(),
key_id: key_id.into_event(),
gap: gap.into_event(),
forward_shift: forward_shift.into_event(),
}
}
}
Expand Down
Loading

0 comments on commit c075830

Please sign in to comment.