Skip to content

Commit

Permalink
feat(s2n-quic-dc): emit cleaner events (#2392)
Browse files Browse the repository at this point in the history
  • Loading branch information
camshaft authored Dec 2, 2024
1 parent b52d7b9 commit 3743cdf
Show file tree
Hide file tree
Showing 11 changed files with 508 additions and 28 deletions.
47 changes: 47 additions & 0 deletions dc/s2n-quic-dc/events/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,50 @@ struct PathSecretMapIdCacheAccessed<'a> {
#[bool_counter("hit")]
hit: bool,
}

#[event("path_secret_map:cleaner_cycled")]
#[subject(endpoint)]
/// Emitted when the cleaner task performed a single cycle
///
/// This can be used to track cache utilization
struct PathSecretMapCleanerCycled {
/// The number of Path Secret ID entries left after the cleaning cycle
#[measure("entries.id")]
id_entries: usize,

/// The number of Path Secret ID entries that were retired in the cycle
#[measure("entries.id.retired")]
id_entries_retired: usize,

/// The utilization percentage of the available number of entries after the cycle
#[measure("entries.id.utilization", Percent)]
id_entries_utilization: f32,

/// The utilization percentage of the available number of entries before the cycle
#[measure("entries.id.utilization.initial", Percent)]
id_entries_initial_utilization: f32,

/// The number of SocketAddress entries left after the cleaning cycle
#[measure("entries.address")]
address_entries: usize,

/// The number of SocketAddress entries that were retired in the cycle
#[measure("entries.address.retired")]
address_entries_retired: usize,

/// The utilization percentage of the available number of address entries after the cycle
#[measure("entries.address.utilization", Percent)]
address_entries_utilization: f32,

/// The utilization percentage of the available number of address entries before the cycle
#[measure("entries.address.utilization.initial", Percent)]
address_entries_initial_utilization: f32,

/// The number of handshake requests that are pending after the cleaning cycle
#[measure("handshake_requests")]
handshake_requests: usize,

/// The number of handshake requests that were retired in the cycle
#[measure("handshake_requests.retired")]
handshake_requests_retired: usize,
}
210 changes: 210 additions & 0 deletions dc/s2n-quic-dc/src/event/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,65 @@ pub mod api {
impl<'a> Event for PathSecretMapIdCacheAccessed<'a> {
const NAME: &'static str = "path_secret_map:id_cache_accessed";
}
#[derive(Clone, Debug)]
#[non_exhaustive]
#[doc = " Emitted when the cleaner task performed a single cycle"]
#[doc = ""]
#[doc = " This can be used to track cache utilization"]
pub struct PathSecretMapCleanerCycled {
#[doc = " The number of Path Secret ID entries left after the cleaning cycle"]
pub id_entries: usize,
#[doc = " The number of Path Secret ID entries that were retired in the cycle"]
pub id_entries_retired: usize,
#[doc = " The utilization percentage of the available number of entries after the cycle"]
pub id_entries_utilization: f32,
#[doc = " The utilization percentage of the available number of entries before the cycle"]
pub id_entries_initial_utilization: f32,
#[doc = " The number of SocketAddress entries left after the cleaning cycle"]
pub address_entries: usize,
#[doc = " The number of SocketAddress entries that were retired in the cycle"]
pub address_entries_retired: usize,
#[doc = " The utilization percentage of the available number of address entries after the cycle"]
pub address_entries_utilization: f32,
#[doc = " The utilization percentage of the available number of address entries before the cycle"]
pub address_entries_initial_utilization: f32,
#[doc = " The number of handshake requests that are pending after the cleaning cycle"]
pub handshake_requests: usize,
#[doc = " The number of handshake requests that were retired in the cycle"]
pub handshake_requests_retired: usize,
}
#[cfg(any(test, feature = "testing"))]
impl crate::event::snapshot::Fmt for PathSecretMapCleanerCycled {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
let mut fmt = fmt.debug_struct("PathSecretMapCleanerCycled");
fmt.field("id_entries", &self.id_entries);
fmt.field("id_entries_retired", &self.id_entries_retired);
fmt.field("id_entries_utilization", &self.id_entries_utilization);
fmt.field(
"id_entries_initial_utilization",
&self.id_entries_initial_utilization,
);
fmt.field("address_entries", &self.address_entries);
fmt.field("address_entries_retired", &self.address_entries_retired);
fmt.field(
"address_entries_utilization",
&self.address_entries_utilization,
);
fmt.field(
"address_entries_initial_utilization",
&self.address_entries_initial_utilization,
);
fmt.field("handshake_requests", &self.handshake_requests);
fmt.field(
"handshake_requests_retired",
&self.handshake_requests_retired,
);
fmt.finish()
}
}
impl Event for PathSecretMapCleanerCycled {
const NAME: &'static str = "path_secret_map:cleaner_cycled";
}
impl IntoEvent<builder::AcceptorPacketDropReason> for s2n_codec::DecoderError {
fn into_event(self) -> builder::AcceptorPacketDropReason {
use builder::AcceptorPacketDropReason as Reason;
Expand Down Expand Up @@ -1849,6 +1908,27 @@ pub mod tracing {
let api::PathSecretMapIdCacheAccessed { credential_id, hit } = event;
tracing :: event ! (target : "path_secret_map_id_cache_accessed" , parent : parent , tracing :: Level :: DEBUG , credential_id = tracing :: field :: debug (credential_id) , hit = tracing :: field :: debug (hit));
}
#[inline]
fn on_path_secret_map_cleaner_cycled(
&self,
meta: &api::EndpointMeta,
event: &api::PathSecretMapCleanerCycled,
) {
let parent = self.parent(meta);
let api::PathSecretMapCleanerCycled {
id_entries,
id_entries_retired,
id_entries_utilization,
id_entries_initial_utilization,
address_entries,
address_entries_retired,
address_entries_utilization,
address_entries_initial_utilization,
handshake_requests,
handshake_requests_retired,
} = event;
tracing :: event ! (target : "path_secret_map_cleaner_cycled" , parent : parent , tracing :: Level :: DEBUG , id_entries = tracing :: field :: debug (id_entries) , id_entries_retired = tracing :: field :: debug (id_entries_retired) , id_entries_utilization = tracing :: field :: debug (id_entries_utilization) , id_entries_initial_utilization = tracing :: field :: debug (id_entries_initial_utilization) , address_entries = tracing :: field :: debug (address_entries) , address_entries_retired = tracing :: field :: debug (address_entries_retired) , address_entries_utilization = tracing :: field :: debug (address_entries_utilization) , address_entries_initial_utilization = tracing :: field :: debug (address_entries_initial_utilization) , handshake_requests = tracing :: field :: debug (handshake_requests) , handshake_requests_retired = tracing :: field :: debug (handshake_requests_retired));
}
}
}
pub mod builder {
Expand Down Expand Up @@ -2995,6 +3075,62 @@ pub mod builder {
}
}
}
#[derive(Clone, Debug)]
#[doc = " Emitted when the cleaner task performed a single cycle"]
#[doc = ""]
#[doc = " This can be used to track cache utilization"]
pub struct PathSecretMapCleanerCycled {
#[doc = " The number of Path Secret ID entries left after the cleaning cycle"]
pub id_entries: usize,
#[doc = " The number of Path Secret ID entries that were retired in the cycle"]
pub id_entries_retired: usize,
#[doc = " The utilization percentage of the available number of entries after the cycle"]
pub id_entries_utilization: f32,
#[doc = " The utilization percentage of the available number of entries before the cycle"]
pub id_entries_initial_utilization: f32,
#[doc = " The number of SocketAddress entries left after the cleaning cycle"]
pub address_entries: usize,
#[doc = " The number of SocketAddress entries that were retired in the cycle"]
pub address_entries_retired: usize,
#[doc = " The utilization percentage of the available number of address entries after the cycle"]
pub address_entries_utilization: f32,
#[doc = " The utilization percentage of the available number of address entries before the cycle"]
pub address_entries_initial_utilization: f32,
#[doc = " The number of handshake requests that are pending after the cleaning cycle"]
pub handshake_requests: usize,
#[doc = " The number of handshake requests that were retired in the cycle"]
pub handshake_requests_retired: usize,
}
impl IntoEvent<api::PathSecretMapCleanerCycled> for PathSecretMapCleanerCycled {
#[inline]
fn into_event(self) -> api::PathSecretMapCleanerCycled {
let PathSecretMapCleanerCycled {
id_entries,
id_entries_retired,
id_entries_utilization,
id_entries_initial_utilization,
address_entries,
address_entries_retired,
address_entries_utilization,
address_entries_initial_utilization,
handshake_requests,
handshake_requests_retired,
} = self;
api::PathSecretMapCleanerCycled {
id_entries: id_entries.into_event(),
id_entries_retired: id_entries_retired.into_event(),
id_entries_utilization: id_entries_utilization.into_event(),
id_entries_initial_utilization: id_entries_initial_utilization.into_event(),
address_entries: address_entries.into_event(),
address_entries_retired: address_entries_retired.into_event(),
address_entries_utilization: address_entries_utilization.into_event(),
address_entries_initial_utilization: address_entries_initial_utilization
.into_event(),
handshake_requests: handshake_requests.into_event(),
handshake_requests_retired: handshake_requests_retired.into_event(),
}
}
}
}
pub use traits::*;
mod traits {
Expand Down Expand Up @@ -3523,6 +3659,16 @@ mod traits {
let _ = meta;
let _ = event;
}
#[doc = "Called when the `PathSecretMapCleanerCycled` event is triggered"]
#[inline]
fn on_path_secret_map_cleaner_cycled(
&self,
meta: &api::EndpointMeta,
event: &api::PathSecretMapCleanerCycled,
) {
let _ = meta;
let _ = event;
}
#[doc = r" Called for each event that relates to the endpoint and all connections"]
#[inline]
fn on_event<M: Meta, E: Event>(&self, meta: &M, event: &E) {
Expand Down Expand Up @@ -3948,6 +4094,14 @@ mod traits {
.on_path_secret_map_id_cache_accessed(meta, event);
}
#[inline]
fn on_path_secret_map_cleaner_cycled(
&self,
meta: &api::EndpointMeta,
event: &api::PathSecretMapCleanerCycled,
) {
self.as_ref().on_path_secret_map_cleaner_cycled(meta, event);
}
#[inline]
fn on_event<M: Meta, E: Event>(&self, meta: &M, event: &E) {
self.as_ref().on_event(meta, event);
}
Expand Down Expand Up @@ -4402,6 +4556,15 @@ mod traits {
(self.1).on_path_secret_map_id_cache_accessed(meta, event);
}
#[inline]
fn on_path_secret_map_cleaner_cycled(
&self,
meta: &api::EndpointMeta,
event: &api::PathSecretMapCleanerCycled,
) {
(self.0).on_path_secret_map_cleaner_cycled(meta, event);
(self.1).on_path_secret_map_cleaner_cycled(meta, event);
}
#[inline]
fn on_event<M: Meta, E: Event>(&self, meta: &M, event: &E) {
self.0.on_event(meta, event);
self.1.on_event(meta, event);
Expand Down Expand Up @@ -4545,6 +4708,8 @@ mod traits {
&self,
event: builder::PathSecretMapIdCacheAccessed,
);
#[doc = "Publishes a `PathSecretMapCleanerCycled` event to the publisher's subscriber"]
fn on_path_secret_map_cleaner_cycled(&self, event: builder::PathSecretMapCleanerCycled);
#[doc = r" Returns the QUIC version, if any"]
fn quic_version(&self) -> Option<u32>;
}
Expand Down Expand Up @@ -4912,6 +5077,13 @@ mod traits {
self.subscriber.on_event(&self.meta, &event);
}
#[inline]
fn on_path_secret_map_cleaner_cycled(&self, event: builder::PathSecretMapCleanerCycled) {
let event = event.into_event();
self.subscriber
.on_path_secret_map_cleaner_cycled(&self.meta, &event);
self.subscriber.on_event(&self.meta, &event);
}
#[inline]
fn quic_version(&self) -> Option<u32> {
self.quic_version
}
Expand Down Expand Up @@ -5041,6 +5213,7 @@ pub mod testing {
pub stale_key_packet_dropped: AtomicU32,
pub path_secret_map_address_cache_accessed: AtomicU32,
pub path_secret_map_id_cache_accessed: AtomicU32,
pub path_secret_map_cleaner_cycled: AtomicU32,
}
impl Drop for Subscriber {
fn drop(&mut self) {
Expand Down Expand Up @@ -5117,6 +5290,7 @@ pub mod testing {
stale_key_packet_dropped: AtomicU32::new(0),
path_secret_map_address_cache_accessed: AtomicU32::new(0),
path_secret_map_id_cache_accessed: AtomicU32::new(0),
path_secret_map_cleaner_cycled: AtomicU32::new(0),
}
}
}
Expand Down Expand Up @@ -5656,6 +5830,18 @@ pub mod testing {
let out = format!("{meta:?} {event:?}");
self.output.lock().unwrap().push(out);
}
fn on_path_secret_map_cleaner_cycled(
&self,
meta: &api::EndpointMeta,
event: &api::PathSecretMapCleanerCycled,
) {
self.path_secret_map_cleaner_cycled
.fetch_add(1, Ordering::Relaxed);
let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
let event = crate::event::snapshot::Fmt::to_snapshot(event);
let out = format!("{meta:?} {event:?}");
self.output.lock().unwrap().push(out);
}
}
}
#[derive(Debug)]
Expand Down Expand Up @@ -5709,6 +5895,7 @@ pub mod testing {
pub stale_key_packet_dropped: AtomicU32,
pub path_secret_map_address_cache_accessed: AtomicU32,
pub path_secret_map_id_cache_accessed: AtomicU32,
pub path_secret_map_cleaner_cycled: AtomicU32,
}
impl Drop for Subscriber {
fn drop(&mut self) {
Expand Down Expand Up @@ -5787,6 +5974,7 @@ pub mod testing {
stale_key_packet_dropped: AtomicU32::new(0),
path_secret_map_address_cache_accessed: AtomicU32::new(0),
path_secret_map_id_cache_accessed: AtomicU32::new(0),
path_secret_map_cleaner_cycled: AtomicU32::new(0),
}
}
}
Expand Down Expand Up @@ -6354,6 +6542,18 @@ pub mod testing {
let out = format!("{meta:?} {event:?}");
self.output.lock().unwrap().push(out);
}
fn on_path_secret_map_cleaner_cycled(
&self,
meta: &api::EndpointMeta,
event: &api::PathSecretMapCleanerCycled,
) {
self.path_secret_map_cleaner_cycled
.fetch_add(1, Ordering::Relaxed);
let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
let event = crate::event::snapshot::Fmt::to_snapshot(event);
let out = format!("{meta:?} {event:?}");
self.output.lock().unwrap().push(out);
}
}
#[derive(Debug)]
pub struct Publisher {
Expand Down Expand Up @@ -6406,6 +6606,7 @@ pub mod testing {
pub stale_key_packet_dropped: AtomicU32,
pub path_secret_map_address_cache_accessed: AtomicU32,
pub path_secret_map_id_cache_accessed: AtomicU32,
pub path_secret_map_cleaner_cycled: AtomicU32,
}
impl Publisher {
#[doc = r" Creates a publisher with snapshot assertions enabled"]
Expand Down Expand Up @@ -6474,6 +6675,7 @@ pub mod testing {
stale_key_packet_dropped: AtomicU32::new(0),
path_secret_map_address_cache_accessed: AtomicU32::new(0),
path_secret_map_id_cache_accessed: AtomicU32::new(0),
path_secret_map_cleaner_cycled: AtomicU32::new(0),
}
}
}
Expand Down Expand Up @@ -6857,6 +7059,14 @@ pub mod testing {
let out = format!("{event:?}");
self.output.lock().unwrap().push(out);
}
fn on_path_secret_map_cleaner_cycled(&self, event: builder::PathSecretMapCleanerCycled) {
self.path_secret_map_cleaner_cycled
.fetch_add(1, Ordering::Relaxed);
let event = event.into_event();
let event = crate::event::snapshot::Fmt::to_snapshot(&event);
let out = format!("{event:?}");
self.output.lock().unwrap().push(out);
}
fn quic_version(&self) -> Option<u32> {
Some(1)
}
Expand Down
Loading

0 comments on commit 3743cdf

Please sign in to comment.