diff --git a/dc/s2n-quic-dc/events/common.rs b/dc/s2n-quic-dc/events/common.rs index 29ce73ff6d..ab462c3201 100644 --- a/dc/s2n-quic-dc/events/common.rs +++ b/dc/s2n-quic-dc/events/common.rs @@ -3,8 +3,11 @@ struct ConnectionMeta { id: u64, + timestamp: Timestamp, } -struct EndpointMeta {} +struct EndpointMeta { + timestamp: Timestamp, +} struct ConnectionInfo {} diff --git a/dc/s2n-quic-dc/events/map.rs b/dc/s2n-quic-dc/events/map.rs index a356832e35..6100804020 100644 --- a/dc/s2n-quic-dc/events/map.rs +++ b/dc/s2n-quic-dc/events/map.rs @@ -19,6 +19,9 @@ struct PathSecretMapUninitialized { /// The number of entries in the map #[measure("entries")] entries: usize, + + #[measure("lifetime")] + lifetime: core::time::Duration, } #[event("path_secret_map:background_handshake_requested")] diff --git a/dc/s2n-quic-dc/src/event.rs b/dc/s2n-quic-dc/src/event.rs index 862d6c3520..90e31b5206 100644 --- a/dc/s2n-quic-dc/src/event.rs +++ b/dc/s2n-quic-dc/src/event.rs @@ -4,7 +4,7 @@ #[cfg(any(test, feature = "testing"))] use s2n_quic_core::event::snapshot; -pub use s2n_quic_core::event::{Event, IntoEvent}; +pub use s2n_quic_core::event::{Event, IntoEvent, Timestamp}; /// Provides metadata related to an event pub trait Meta: core::fmt::Debug { diff --git a/dc/s2n-quic-dc/src/event/generated.rs b/dc/s2n-quic-dc/src/event/generated.rs index d22529cf5e..da925b9116 100644 --- a/dc/s2n-quic-dc/src/event/generated.rs +++ b/dc/s2n-quic-dc/src/event/generated.rs @@ -18,22 +18,27 @@ pub mod api { #[non_exhaustive] pub struct ConnectionMeta { pub id: u64, + pub timestamp: Timestamp, } #[cfg(any(test, feature = "testing"))] impl crate::event::snapshot::Fmt for ConnectionMeta { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { let mut fmt = fmt.debug_struct("ConnectionMeta"); fmt.field("id", &self.id); + fmt.field("timestamp", &self.timestamp); fmt.finish() } } #[derive(Clone, Debug)] #[non_exhaustive] - pub struct EndpointMeta {} + pub struct EndpointMeta { + pub timestamp: Timestamp, + } #[cfg(any(test, feature = "testing"))] impl crate::event::snapshot::Fmt for EndpointMeta { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { let mut fmt = fmt.debug_struct("EndpointMeta"); + fmt.field("timestamp", &self.timestamp); fmt.finish() } } @@ -133,6 +138,7 @@ pub mod api { pub capacity: usize, #[doc = " The number of entries in the map"] pub entries: usize, + pub lifetime: core::time::Duration, } #[cfg(any(test, feature = "testing"))] impl crate::event::snapshot::Fmt for PathSecretMapUninitialized { @@ -140,6 +146,7 @@ pub mod api { let mut fmt = fmt.debug_struct("PathSecretMapUninitialized"); fmt.field("capacity", &self.capacity); fmt.field("entries", &self.entries); + fmt.field("lifetime", &self.lifetime); fmt.finish() } } @@ -637,8 +644,12 @@ pub mod tracing { event: &api::PathSecretMapUninitialized, ) { let parent = self.parent(meta); - let api::PathSecretMapUninitialized { capacity, entries } = event; - tracing :: event ! (target : "path_secret_map_uninitialized" , parent : parent , tracing :: Level :: DEBUG , capacity = tracing :: field :: debug (capacity) , entries = tracing :: field :: debug (entries)); + let api::PathSecretMapUninitialized { + capacity, + entries, + lifetime, + } = event; + tracing :: event ! (target : "path_secret_map_uninitialized" , parent : parent , tracing :: Level :: DEBUG , capacity = tracing :: field :: debug (capacity) , entries = tracing :: field :: debug (entries) , lifetime = tracing :: field :: debug (lifetime)); } #[inline] fn on_path_secret_map_background_handshake_requested( @@ -921,23 +932,29 @@ pub mod builder { #[derive(Clone, Debug)] pub struct ConnectionMeta { pub id: u64, + pub timestamp: Timestamp, } impl IntoEvent for ConnectionMeta { #[inline] fn into_event(self) -> api::ConnectionMeta { - let ConnectionMeta { id } = self; + let ConnectionMeta { id, timestamp } = self; api::ConnectionMeta { id: id.into_event(), + timestamp: timestamp.into_event(), } } } #[derive(Clone, Debug)] - pub struct EndpointMeta {} + pub struct EndpointMeta { + pub timestamp: Timestamp, + } impl IntoEvent for EndpointMeta { #[inline] fn into_event(self) -> api::EndpointMeta { - let EndpointMeta {} = self; - api::EndpointMeta {} + let EndpointMeta { timestamp } = self; + api::EndpointMeta { + timestamp: timestamp.into_event(), + } } } #[derive(Clone, Debug)] @@ -1030,14 +1047,20 @@ pub mod builder { pub capacity: usize, #[doc = " The number of entries in the map"] pub entries: usize, + pub lifetime: core::time::Duration, } impl IntoEvent for PathSecretMapUninitialized { #[inline] fn into_event(self) -> api::PathSecretMapUninitialized { - let PathSecretMapUninitialized { capacity, entries } = self; + let PathSecretMapUninitialized { + capacity, + entries, + lifetime, + } = self; api::PathSecretMapUninitialized { capacity: capacity.into_event(), entries: entries.into_event(), + lifetime: lifetime.into_event(), } } } diff --git a/dc/s2n-quic-dc/src/event/generated/metrics/aggregate.rs b/dc/s2n-quic-dc/src/event/generated/metrics/aggregate.rs index bd168cb728..aab028c17a 100644 --- a/dc/s2n-quic-dc/src/event/generated/metrics/aggregate.rs +++ b/dc/s2n-quic-dc/src/event/generated/metrics/aggregate.rs @@ -12,7 +12,7 @@ use crate::event::{ AsVariant, BoolRecorder, Info, Metric, NominalRecorder, Recorder, Registry, Units, }, }; -static INFO: &[Info; 59usize] = &[ +static INFO: &[Info; 60usize] = &[ info::Builder { id: 0usize, name: Str::new("application_write\0"), @@ -123,251 +123,262 @@ static INFO: &[Info; 59usize] = &[ .build(), info::Builder { id: 18usize, - name: Str::new("path_secret_map_background_handshake_requested\0"), + name: Str::new("path_secret_map_uninitialized.lifetime\0"), units: Units::None, } .build(), info::Builder { id: 19usize, - name: Str::new("path_secret_map_background_handshake_requested.peer_address.protocol\0"), + name: Str::new("path_secret_map_background_handshake_requested\0"), units: Units::None, } .build(), info::Builder { id: 20usize, - name: Str::new("path_secret_map_entry_inserted\0"), + name: Str::new("path_secret_map_background_handshake_requested.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 21usize, - name: Str::new("path_secret_map_entry_inserted.peer_address.protocol\0"), + name: Str::new("path_secret_map_entry_inserted\0"), units: Units::None, } .build(), info::Builder { id: 22usize, - name: Str::new("path_secret_map_entry_ready\0"), + name: Str::new("path_secret_map_entry_inserted.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 23usize, - name: Str::new("path_secret_map_entry_ready.peer_address.protocol\0"), + name: Str::new("path_secret_map_entry_ready\0"), units: Units::None, } .build(), info::Builder { id: 24usize, - name: Str::new("path_secret_map_entry_replaced\0"), + name: Str::new("path_secret_map_entry_ready.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 25usize, - name: Str::new("path_secret_map_entry_replaced.peer_address.protocol\0"), + name: Str::new("path_secret_map_entry_replaced\0"), units: Units::None, } .build(), info::Builder { id: 26usize, - name: Str::new("unknown_path_secret_packet_sent\0"), + name: Str::new("path_secret_map_entry_replaced.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 27usize, - name: Str::new("unknown_path_secret_packet_sent.peer_address.protocol\0"), + name: Str::new("unknown_path_secret_packet_sent\0"), units: Units::None, } .build(), info::Builder { id: 28usize, - name: Str::new("unknown_path_secret_packet_received\0"), + name: Str::new("unknown_path_secret_packet_sent.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 29usize, - name: Str::new("unknown_path_secret_packet_received.peer_address.protocol\0"), + name: Str::new("unknown_path_secret_packet_received\0"), units: Units::None, } .build(), info::Builder { id: 30usize, - name: Str::new("unknown_path_secret_packet_accepted\0"), + name: Str::new("unknown_path_secret_packet_received.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 31usize, - name: Str::new("unknown_path_secret_packet_accepted.peer_address.protocol\0"), + name: Str::new("unknown_path_secret_packet_accepted\0"), units: Units::None, } .build(), info::Builder { id: 32usize, - name: Str::new("unknown_path_secret_packet_rejected\0"), + name: Str::new("unknown_path_secret_packet_accepted.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 33usize, - name: Str::new("unknown_path_secret_packet_rejected.peer_address.protocol\0"), + name: Str::new("unknown_path_secret_packet_rejected\0"), units: Units::None, } .build(), info::Builder { id: 34usize, - name: Str::new("unknown_path_secret_packet_dropped\0"), + name: Str::new("unknown_path_secret_packet_rejected.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 35usize, - name: Str::new("unknown_path_secret_packet_dropped.peer_address.protocol\0"), + name: Str::new("unknown_path_secret_packet_dropped\0"), units: Units::None, } .build(), info::Builder { id: 36usize, - name: Str::new("replay_definitely_detected\0"), + name: Str::new("unknown_path_secret_packet_dropped.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 37usize, - name: Str::new("replay_potentially_detected\0"), + name: Str::new("replay_definitely_detected\0"), units: Units::None, } .build(), info::Builder { id: 38usize, - name: Str::new("replay_potentially_detected.gap\0"), + name: Str::new("replay_potentially_detected\0"), units: Units::None, } .build(), info::Builder { id: 39usize, - name: Str::new("replay_detected_packet_sent\0"), + name: Str::new("replay_potentially_detected.gap\0"), units: Units::None, } .build(), info::Builder { id: 40usize, - name: Str::new("replay_detected_packet_sent.peer_address.protocol\0"), + name: Str::new("replay_detected_packet_sent\0"), units: Units::None, } .build(), info::Builder { id: 41usize, - name: Str::new("replay_detected_packet_received\0"), + name: Str::new("replay_detected_packet_sent.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 42usize, - name: Str::new("replay_detected_packet_received.peer_address.protocol\0"), + name: Str::new("replay_detected_packet_received\0"), units: Units::None, } .build(), info::Builder { id: 43usize, - name: Str::new("replay_detected_packet_accepted\0"), + name: Str::new("replay_detected_packet_received.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 44usize, - name: Str::new("replay_detected_packet_accepted.peer_address.protocol\0"), + name: Str::new("replay_detected_packet_accepted\0"), units: Units::None, } .build(), info::Builder { id: 45usize, - name: Str::new("replay_detected_packet_rejected\0"), + name: Str::new("replay_detected_packet_accepted.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 46usize, - name: Str::new("replay_detected_packet_rejected.peer_address.protocol\0"), + name: Str::new("replay_detected_packet_rejected\0"), units: Units::None, } .build(), info::Builder { id: 47usize, - name: Str::new("replay_detected_packet_dropped\0"), + name: Str::new("replay_detected_packet_rejected.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 48usize, - name: Str::new("replay_detected_packet_dropped.peer_address.protocol\0"), + name: Str::new("replay_detected_packet_dropped\0"), units: Units::None, } .build(), info::Builder { id: 49usize, - name: Str::new("stale_key_packet_sent\0"), + name: Str::new("replay_detected_packet_dropped.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 50usize, - name: Str::new("stale_key_packet_sent.peer_address.protocol\0"), + name: Str::new("stale_key_packet_sent\0"), units: Units::None, } .build(), info::Builder { id: 51usize, - name: Str::new("stale_key_packet_received\0"), + name: Str::new("stale_key_packet_sent.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 52usize, - name: Str::new("stale_key_packet_received.peer_address.protocol\0"), + name: Str::new("stale_key_packet_received\0"), units: Units::None, } .build(), info::Builder { id: 53usize, - name: Str::new("stale_key_packet_accepted\0"), + name: Str::new("stale_key_packet_received.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 54usize, - name: Str::new("stale_key_packet_accepted.peer_address.protocol\0"), + name: Str::new("stale_key_packet_accepted\0"), units: Units::None, } .build(), info::Builder { id: 55usize, - name: Str::new("stale_key_packet_rejected\0"), + name: Str::new("stale_key_packet_accepted.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 56usize, - name: Str::new("stale_key_packet_rejected.peer_address.protocol\0"), + name: Str::new("stale_key_packet_rejected\0"), units: Units::None, } .build(), info::Builder { id: 57usize, - name: Str::new("stale_key_packet_dropped\0"), + name: Str::new("stale_key_packet_rejected.peer_address.protocol\0"), units: Units::None, } .build(), info::Builder { id: 58usize, + name: Str::new("stale_key_packet_dropped\0"), + units: Units::None, + } + .build(), + info::Builder { + id: 59usize, name: Str::new("stale_key_packet_dropped.peer_address.protocol\0"), units: Units::None, } .build(), ]; +#[derive(Clone, Copy, Debug)] +#[allow(dead_code)] +pub struct ConnectionContext { + start_time: crate::event::Timestamp, +} pub struct Subscriber { #[allow(dead_code)] counters: Box<[R::Counter; 28usize]>, @@ -376,14 +387,18 @@ pub struct Subscriber { #[allow(dead_code)] nominal_counters: Box<[R::NominalCounter]>, #[allow(dead_code)] - nominal_offsets: Box<[usize; 21usize]>, + nominal_counter_offsets: Box<[usize; 21usize]>, #[allow(dead_code)] - measures: Box<[R::Measure; 8usize]>, + measures: Box<[R::Measure; 9usize]>, #[allow(dead_code)] gauges: Box<[R::Gauge; 0usize]>, #[allow(dead_code)] timers: Box<[R::Timer; 0usize]>, #[allow(dead_code)] + nominal_timers: Box<[R::NominalTimer]>, + #[allow(dead_code)] + nominal_timer_offsets: Box<[usize; 0usize]>, + #[allow(dead_code)] registry: R, } impl Default for Subscriber { @@ -403,11 +418,13 @@ impl Subscriber { pub fn new(registry: R) -> Self { let mut counters = Vec::with_capacity(28usize); let mut bool_counters = Vec::with_capacity(2usize); - let mut nominal_offsets = Vec::with_capacity(21usize); let mut nominal_counters = Vec::with_capacity(21usize); - let mut measures = Vec::with_capacity(8usize); + let mut nominal_counter_offsets = Vec::with_capacity(21usize); + let mut measures = Vec::with_capacity(9usize); let mut gauges = Vec::with_capacity(0usize); let mut timers = Vec::with_capacity(0usize); + let mut nominal_timers = Vec::with_capacity(0usize); + let mut nominal_timer_offsets = Vec::with_capacity(0usize); counters.push(registry.register_counter(&INFO[0usize])); counters.push(registry.register_counter(&INFO[2usize])); counters.push(registry.register_counter(&INFO[4usize])); @@ -415,27 +432,27 @@ impl Subscriber { counters.push(registry.register_counter(&INFO[8usize])); counters.push(registry.register_counter(&INFO[13usize])); counters.push(registry.register_counter(&INFO[15usize])); - counters.push(registry.register_counter(&INFO[18usize])); - counters.push(registry.register_counter(&INFO[20usize])); - counters.push(registry.register_counter(&INFO[22usize])); - counters.push(registry.register_counter(&INFO[24usize])); - counters.push(registry.register_counter(&INFO[26usize])); - counters.push(registry.register_counter(&INFO[28usize])); - counters.push(registry.register_counter(&INFO[30usize])); - counters.push(registry.register_counter(&INFO[32usize])); - counters.push(registry.register_counter(&INFO[34usize])); - counters.push(registry.register_counter(&INFO[36usize])); + counters.push(registry.register_counter(&INFO[19usize])); + counters.push(registry.register_counter(&INFO[21usize])); + counters.push(registry.register_counter(&INFO[23usize])); + counters.push(registry.register_counter(&INFO[25usize])); + counters.push(registry.register_counter(&INFO[27usize])); + counters.push(registry.register_counter(&INFO[29usize])); + counters.push(registry.register_counter(&INFO[31usize])); + counters.push(registry.register_counter(&INFO[33usize])); + counters.push(registry.register_counter(&INFO[35usize])); counters.push(registry.register_counter(&INFO[37usize])); - counters.push(registry.register_counter(&INFO[39usize])); - counters.push(registry.register_counter(&INFO[41usize])); - counters.push(registry.register_counter(&INFO[43usize])); - counters.push(registry.register_counter(&INFO[45usize])); - counters.push(registry.register_counter(&INFO[47usize])); - counters.push(registry.register_counter(&INFO[49usize])); - counters.push(registry.register_counter(&INFO[51usize])); - counters.push(registry.register_counter(&INFO[53usize])); - counters.push(registry.register_counter(&INFO[55usize])); - counters.push(registry.register_counter(&INFO[57usize])); + counters.push(registry.register_counter(&INFO[38usize])); + counters.push(registry.register_counter(&INFO[40usize])); + counters.push(registry.register_counter(&INFO[42usize])); + counters.push(registry.register_counter(&INFO[44usize])); + counters.push(registry.register_counter(&INFO[46usize])); + counters.push(registry.register_counter(&INFO[48usize])); + counters.push(registry.register_counter(&INFO[50usize])); + counters.push(registry.register_counter(&INFO[52usize])); + counters.push(registry.register_counter(&INFO[54usize])); + counters.push(registry.register_counter(&INFO[56usize])); + counters.push(registry.register_counter(&INFO[58usize])); bool_counters.push(registry.register_bool_counter(&INFO[11usize])); bool_counters.push(registry.register_bool_counter(&INFO[12usize])); { @@ -450,7 +467,7 @@ impl Subscriber { count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); @@ -461,216 +478,216 @@ impl Subscriber { count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[19usize], variant)); + .push(registry.register_nominal_counter(&INFO[20usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[21usize], variant)); + .push(registry.register_nominal_counter(&INFO[22usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[23usize], variant)); + .push(registry.register_nominal_counter(&INFO[24usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[25usize], variant)); + .push(registry.register_nominal_counter(&INFO[26usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[27usize], variant)); + .push(registry.register_nominal_counter(&INFO[28usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[29usize], variant)); + .push(registry.register_nominal_counter(&INFO[30usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[31usize], variant)); + .push(registry.register_nominal_counter(&INFO[32usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[33usize], variant)); + .push(registry.register_nominal_counter(&INFO[34usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[35usize], variant)); + .push(registry.register_nominal_counter(&INFO[36usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[40usize], variant)); + .push(registry.register_nominal_counter(&INFO[41usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[42usize], variant)); + .push(registry.register_nominal_counter(&INFO[43usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[44usize], variant)); + .push(registry.register_nominal_counter(&INFO[45usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[46usize], variant)); + .push(registry.register_nominal_counter(&INFO[47usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[48usize], variant)); + .push(registry.register_nominal_counter(&INFO[49usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[50usize], variant)); + .push(registry.register_nominal_counter(&INFO[51usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[52usize], variant)); + .push(registry.register_nominal_counter(&INFO[53usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[54usize], variant)); + .push(registry.register_nominal_counter(&INFO[55usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[56usize], variant)); + .push(registry.register_nominal_counter(&INFO[57usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[58usize], variant)); + .push(registry.register_nominal_counter(&INFO[59usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } } measures.push(registry.register_measure(&INFO[1usize])); @@ -680,7 +697,12 @@ impl Subscriber { measures.push(registry.register_measure(&INFO[14usize])); measures.push(registry.register_measure(&INFO[16usize])); measures.push(registry.register_measure(&INFO[17usize])); - measures.push(registry.register_measure(&INFO[38usize])); + measures.push(registry.register_measure(&INFO[18usize])); + measures.push(registry.register_measure(&INFO[39usize])); + { + #[allow(unused_imports)] + use api::*; + } Self { counters: counters .try_into() @@ -689,7 +711,7 @@ impl Subscriber { .try_into() .unwrap_or_else(|_| panic!("invalid len")), nominal_counters: nominal_counters.into(), - nominal_offsets: nominal_offsets + nominal_counter_offsets: nominal_counter_offsets .try_into() .unwrap_or_else(|_| panic!("invalid len")), measures: measures @@ -697,6 +719,10 @@ impl Subscriber { .unwrap_or_else(|_| panic!("invalid len")), gauges: gauges.try_into().unwrap_or_else(|_| panic!("invalid len")), timers: timers.try_into().unwrap_or_else(|_| panic!("invalid len")), + nominal_timers: nominal_timers.into(), + nominal_timer_offsets: nominal_timer_offsets + .try_into() + .unwrap_or_else(|_| panic!("invalid len")), registry, } } @@ -714,27 +740,27 @@ impl Subscriber { 4usize => (&INFO[8usize], entry), 5usize => (&INFO[13usize], entry), 6usize => (&INFO[15usize], entry), - 7usize => (&INFO[18usize], entry), - 8usize => (&INFO[20usize], entry), - 9usize => (&INFO[22usize], entry), - 10usize => (&INFO[24usize], entry), - 11usize => (&INFO[26usize], entry), - 12usize => (&INFO[28usize], entry), - 13usize => (&INFO[30usize], entry), - 14usize => (&INFO[32usize], entry), - 15usize => (&INFO[34usize], entry), - 16usize => (&INFO[36usize], entry), - 17usize => (&INFO[37usize], entry), - 18usize => (&INFO[39usize], entry), - 19usize => (&INFO[41usize], entry), - 20usize => (&INFO[43usize], entry), - 21usize => (&INFO[45usize], entry), - 22usize => (&INFO[47usize], entry), - 23usize => (&INFO[49usize], entry), - 24usize => (&INFO[51usize], entry), - 25usize => (&INFO[53usize], entry), - 26usize => (&INFO[55usize], entry), - 27usize => (&INFO[57usize], entry), + 7usize => (&INFO[19usize], entry), + 8usize => (&INFO[21usize], entry), + 9usize => (&INFO[23usize], entry), + 10usize => (&INFO[25usize], entry), + 11usize => (&INFO[27usize], entry), + 12usize => (&INFO[29usize], entry), + 13usize => (&INFO[31usize], entry), + 14usize => (&INFO[33usize], entry), + 15usize => (&INFO[35usize], entry), + 16usize => (&INFO[37usize], entry), + 17usize => (&INFO[38usize], entry), + 18usize => (&INFO[40usize], entry), + 19usize => (&INFO[42usize], entry), + 20usize => (&INFO[44usize], entry), + 21usize => (&INFO[46usize], entry), + 22usize => (&INFO[48usize], entry), + 23usize => (&INFO[50usize], entry), + 24usize => (&INFO[52usize], entry), + 25usize => (&INFO[54usize], entry), + 26usize => (&INFO[56usize], entry), + 27usize => (&INFO[58usize], entry), _ => unsafe { core::hint::unreachable_unchecked() }, }) } @@ -770,7 +796,7 @@ impl Subscriber { &self, ) -> impl Iterator + '_ { use api::*; - self.nominal_offsets + self.nominal_counter_offsets .iter() .enumerate() .map(|(idx, entry)| match idx { @@ -790,115 +816,115 @@ impl Subscriber { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[19usize], entries, variants) + (&INFO[20usize], entries, variants) } 3usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[21usize], entries, variants) + (&INFO[22usize], entries, variants) } 4usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[23usize], entries, variants) + (&INFO[24usize], entries, variants) } 5usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[25usize], entries, variants) + (&INFO[26usize], entries, variants) } 6usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[27usize], entries, variants) + (&INFO[28usize], entries, variants) } 7usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[29usize], entries, variants) + (&INFO[30usize], entries, variants) } 8usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[31usize], entries, variants) + (&INFO[32usize], entries, variants) } 9usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[33usize], entries, variants) + (&INFO[34usize], entries, variants) } 10usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[35usize], entries, variants) + (&INFO[36usize], entries, variants) } 11usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[40usize], entries, variants) + (&INFO[41usize], entries, variants) } 12usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[42usize], entries, variants) + (&INFO[43usize], entries, variants) } 13usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[44usize], entries, variants) + (&INFO[45usize], entries, variants) } 14usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[46usize], entries, variants) + (&INFO[47usize], entries, variants) } 15usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[48usize], entries, variants) + (&INFO[49usize], entries, variants) } 16usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[50usize], entries, variants) + (&INFO[51usize], entries, variants) } 17usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[52usize], entries, variants) + (&INFO[53usize], entries, variants) } 18usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[54usize], entries, variants) + (&INFO[55usize], entries, variants) } 19usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[56usize], entries, variants) + (&INFO[57usize], entries, variants) } 20usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[58usize], entries, variants) + (&INFO[59usize], entries, variants) } _ => unsafe { core::hint::unreachable_unchecked() }, }) @@ -907,7 +933,7 @@ impl Subscriber { #[inline(always)] fn count_nominal(&self, info: usize, id: usize, value: &T) { let info = &INFO[info]; - let idx = self.nominal_offsets[id] + value.variant_idx(); + let idx = self.nominal_counter_offsets[id] + value.variant_idx(); let counter = &self.nominal_counters[idx]; counter.record(info, value.as_variant(), 1usize); } @@ -925,7 +951,8 @@ impl Subscriber { 4usize => (&INFO[14usize], entry), 5usize => (&INFO[16usize], entry), 6usize => (&INFO[17usize], entry), - 7usize => (&INFO[38usize], entry), + 7usize => (&INFO[18usize], entry), + 8usize => (&INFO[39usize], entry), _ => unsafe { core::hint::unreachable_unchecked() }, }) } @@ -960,14 +987,31 @@ impl Subscriber { let timer = &self.timers[id]; timer.record(info, value); } + #[allow(dead_code)] + #[inline(always)] + fn time_nominal( + &self, + info: usize, + id: usize, + value: &T, + duration: core::time::Duration, + ) { + let info = &INFO[info]; + let idx = self.nominal_timer_offsets[id] + value.variant_idx(); + let counter = &self.nominal_timers[idx]; + counter.record(info, value.as_variant(), duration); + } } impl event::Subscriber for Subscriber { - type ConnectionContext = (); + type ConnectionContext = ConnectionContext; fn create_connection_context( &self, - _meta: &api::ConnectionMeta, + meta: &api::ConnectionMeta, _info: &api::ConnectionInfo, ) -> Self::ConnectionContext { + Self::ConnectionContext { + start_time: meta.timestamp, + } } #[inline] fn on_application_write( @@ -976,6 +1020,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::ApplicationWrite, ) { + #[allow(unused_imports)] + use api::*; self.count(0usize, 0usize, 1usize); self.measure(1usize, 0usize, event.total_len); self.count(2usize, 1usize, event.write_len); @@ -991,6 +1037,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::ApplicationRead, ) { + #[allow(unused_imports)] + use api::*; self.count(4usize, 2usize, 1usize); self.measure(5usize, 2usize, event.capacity); self.count(6usize, 3usize, event.read_len); @@ -1001,6 +1049,8 @@ impl event::Subscriber for Subscriber { } #[inline] fn on_endpoint_initialized(&self, meta: &api::EndpointMeta, event: &api::EndpointInitialized) { + #[allow(unused_imports)] + use api::*; self.count(8usize, 4usize, 1usize); self.count_nominal(9usize, 0usize, &event.acceptor_addr); self.count_nominal(10usize, 1usize, &event.handshake_addr); @@ -1015,6 +1065,8 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::PathSecretMapInitialized, ) { + #[allow(unused_imports)] + use api::*; self.count(13usize, 5usize, 1usize); self.measure(14usize, 4usize, event.capacity); let _ = event; @@ -1026,9 +1078,12 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::PathSecretMapUninitialized, ) { + #[allow(unused_imports)] + use api::*; self.count(15usize, 6usize, 1usize); self.measure(16usize, 5usize, event.capacity); self.measure(17usize, 6usize, event.entries); + self.measure(18usize, 7usize, event.lifetime); let _ = event; let _ = meta; } @@ -1038,8 +1093,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::PathSecretMapBackgroundHandshakeRequested, ) { - self.count(18usize, 7usize, 1usize); - self.count_nominal(19usize, 2usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(19usize, 7usize, 1usize); + self.count_nominal(20usize, 2usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1049,8 +1106,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::PathSecretMapEntryInserted, ) { - self.count(20usize, 8usize, 1usize); - self.count_nominal(21usize, 3usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(21usize, 8usize, 1usize); + self.count_nominal(22usize, 3usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1060,8 +1119,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::PathSecretMapEntryReady, ) { - self.count(22usize, 9usize, 1usize); - self.count_nominal(23usize, 4usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(23usize, 9usize, 1usize); + self.count_nominal(24usize, 4usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1071,8 +1132,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::PathSecretMapEntryReplaced, ) { - self.count(24usize, 10usize, 1usize); - self.count_nominal(25usize, 5usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(25usize, 10usize, 1usize); + self.count_nominal(26usize, 5usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1082,8 +1145,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::UnknownPathSecretPacketSent, ) { - self.count(26usize, 11usize, 1usize); - self.count_nominal(27usize, 6usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(27usize, 11usize, 1usize); + self.count_nominal(28usize, 6usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1093,8 +1158,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::UnknownPathSecretPacketReceived, ) { - self.count(28usize, 12usize, 1usize); - self.count_nominal(29usize, 7usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(29usize, 12usize, 1usize); + self.count_nominal(30usize, 7usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1104,8 +1171,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::UnknownPathSecretPacketAccepted, ) { - self.count(30usize, 13usize, 1usize); - self.count_nominal(31usize, 8usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(31usize, 13usize, 1usize); + self.count_nominal(32usize, 8usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1115,8 +1184,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::UnknownPathSecretPacketRejected, ) { - self.count(32usize, 14usize, 1usize); - self.count_nominal(33usize, 9usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(33usize, 14usize, 1usize); + self.count_nominal(34usize, 9usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1126,8 +1197,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::UnknownPathSecretPacketDropped, ) { - self.count(34usize, 15usize, 1usize); - self.count_nominal(35usize, 10usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(35usize, 15usize, 1usize); + self.count_nominal(36usize, 10usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1137,7 +1210,9 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::ReplayDefinitelyDetected, ) { - self.count(36usize, 16usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(37usize, 16usize, 1usize); let _ = event; let _ = meta; } @@ -1147,8 +1222,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::ReplayPotentiallyDetected, ) { - self.count(37usize, 17usize, 1usize); - self.measure(38usize, 7usize, event.gap); + #[allow(unused_imports)] + use api::*; + self.count(38usize, 17usize, 1usize); + self.measure(39usize, 8usize, event.gap); let _ = event; let _ = meta; } @@ -1158,8 +1235,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::ReplayDetectedPacketSent, ) { - self.count(39usize, 18usize, 1usize); - self.count_nominal(40usize, 11usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(40usize, 18usize, 1usize); + self.count_nominal(41usize, 11usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1169,8 +1248,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::ReplayDetectedPacketReceived, ) { - self.count(41usize, 19usize, 1usize); - self.count_nominal(42usize, 12usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(42usize, 19usize, 1usize); + self.count_nominal(43usize, 12usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1180,8 +1261,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::ReplayDetectedPacketAccepted, ) { - self.count(43usize, 20usize, 1usize); - self.count_nominal(44usize, 13usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(44usize, 20usize, 1usize); + self.count_nominal(45usize, 13usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1191,8 +1274,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::ReplayDetectedPacketRejected, ) { - self.count(45usize, 21usize, 1usize); - self.count_nominal(46usize, 14usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(46usize, 21usize, 1usize); + self.count_nominal(47usize, 14usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1202,15 +1287,19 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::ReplayDetectedPacketDropped, ) { - self.count(47usize, 22usize, 1usize); - self.count_nominal(48usize, 15usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(48usize, 22usize, 1usize); + self.count_nominal(49usize, 15usize, &event.peer_address); let _ = event; let _ = meta; } #[inline] fn on_stale_key_packet_sent(&self, meta: &api::EndpointMeta, event: &api::StaleKeyPacketSent) { - self.count(49usize, 23usize, 1usize); - self.count_nominal(50usize, 16usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(50usize, 23usize, 1usize); + self.count_nominal(51usize, 16usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1220,8 +1309,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::StaleKeyPacketReceived, ) { - self.count(51usize, 24usize, 1usize); - self.count_nominal(52usize, 17usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(52usize, 24usize, 1usize); + self.count_nominal(53usize, 17usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1231,8 +1322,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::StaleKeyPacketAccepted, ) { - self.count(53usize, 25usize, 1usize); - self.count_nominal(54usize, 18usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(54usize, 25usize, 1usize); + self.count_nominal(55usize, 18usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1242,8 +1335,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::StaleKeyPacketRejected, ) { - self.count(55usize, 26usize, 1usize); - self.count_nominal(56usize, 19usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(56usize, 26usize, 1usize); + self.count_nominal(57usize, 19usize, &event.peer_address); let _ = event; let _ = meta; } @@ -1253,8 +1348,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::StaleKeyPacketDropped, ) { - self.count(57usize, 27usize, 1usize); - self.count_nominal(58usize, 20usize, &event.peer_address); + #[allow(unused_imports)] + use api::*; + self.count(58usize, 27usize, 1usize); + self.count_nominal(59usize, 20usize, &event.peer_address); let _ = event; let _ = meta; } diff --git a/dc/s2n-quic-dc/src/event/generated/metrics/probe.rs b/dc/s2n-quic-dc/src/event/generated/metrics/probe.rs index 1e861382e5..0b4a4d1d2d 100644 --- a/dc/s2n-quic-dc/src/event/generated/metrics/probe.rs +++ b/dc/s2n-quic-dc/src/event/generated/metrics/probe.rs @@ -24,27 +24,27 @@ mod counter { 8usize => Self(endpoint_initialized), 13usize => Self(path_secret_map_initialized), 15usize => Self(path_secret_map_uninitialized), - 18usize => Self(path_secret_map_background_handshake_requested), - 20usize => Self(path_secret_map_entry_inserted), - 22usize => Self(path_secret_map_entry_ready), - 24usize => Self(path_secret_map_entry_replaced), - 26usize => Self(unknown_path_secret_packet_sent), - 28usize => Self(unknown_path_secret_packet_received), - 30usize => Self(unknown_path_secret_packet_accepted), - 32usize => Self(unknown_path_secret_packet_rejected), - 34usize => Self(unknown_path_secret_packet_dropped), - 36usize => Self(replay_definitely_detected), - 37usize => Self(replay_potentially_detected), - 39usize => Self(replay_detected_packet_sent), - 41usize => Self(replay_detected_packet_received), - 43usize => Self(replay_detected_packet_accepted), - 45usize => Self(replay_detected_packet_rejected), - 47usize => Self(replay_detected_packet_dropped), - 49usize => Self(stale_key_packet_sent), - 51usize => Self(stale_key_packet_received), - 53usize => Self(stale_key_packet_accepted), - 55usize => Self(stale_key_packet_rejected), - 57usize => Self(stale_key_packet_dropped), + 19usize => Self(path_secret_map_background_handshake_requested), + 21usize => Self(path_secret_map_entry_inserted), + 23usize => Self(path_secret_map_entry_ready), + 25usize => Self(path_secret_map_entry_replaced), + 27usize => Self(unknown_path_secret_packet_sent), + 29usize => Self(unknown_path_secret_packet_received), + 31usize => Self(unknown_path_secret_packet_accepted), + 33usize => Self(unknown_path_secret_packet_rejected), + 35usize => Self(unknown_path_secret_packet_dropped), + 37usize => Self(replay_definitely_detected), + 38usize => Self(replay_potentially_detected), + 40usize => Self(replay_detected_packet_sent), + 42usize => Self(replay_detected_packet_received), + 44usize => Self(replay_detected_packet_accepted), + 46usize => Self(replay_detected_packet_rejected), + 48usize => Self(replay_detected_packet_dropped), + 50usize => Self(stale_key_packet_sent), + 52usize => Self(stale_key_packet_received), + 54usize => Self(stale_key_packet_accepted), + 56usize => Self(stale_key_packet_rejected), + 58usize => Self(stale_key_packet_dropped), _ => unreachable!("invalid info: {info:?}"), } } @@ -151,27 +151,27 @@ mod counter { match info.id { 9usize => Self(endpoint_initialized__acceptor__protocol), 10usize => Self(endpoint_initialized__handshake__protocol), - 19usize => { + 20usize => { Self(path_secret_map_background_handshake_requested__peer_address__protocol) } - 21usize => Self(path_secret_map_entry_inserted__peer_address__protocol), - 23usize => Self(path_secret_map_entry_ready__peer_address__protocol), - 25usize => Self(path_secret_map_entry_replaced__peer_address__protocol), - 27usize => Self(unknown_path_secret_packet_sent__peer_address__protocol), - 29usize => Self(unknown_path_secret_packet_received__peer_address__protocol), - 31usize => Self(unknown_path_secret_packet_accepted__peer_address__protocol), - 33usize => Self(unknown_path_secret_packet_rejected__peer_address__protocol), - 35usize => Self(unknown_path_secret_packet_dropped__peer_address__protocol), - 40usize => Self(replay_detected_packet_sent__peer_address__protocol), - 42usize => Self(replay_detected_packet_received__peer_address__protocol), - 44usize => Self(replay_detected_packet_accepted__peer_address__protocol), - 46usize => Self(replay_detected_packet_rejected__peer_address__protocol), - 48usize => Self(replay_detected_packet_dropped__peer_address__protocol), - 50usize => Self(stale_key_packet_sent__peer_address__protocol), - 52usize => Self(stale_key_packet_received__peer_address__protocol), - 54usize => Self(stale_key_packet_accepted__peer_address__protocol), - 56usize => Self(stale_key_packet_rejected__peer_address__protocol), - 58usize => Self(stale_key_packet_dropped__peer_address__protocol), + 22usize => Self(path_secret_map_entry_inserted__peer_address__protocol), + 24usize => Self(path_secret_map_entry_ready__peer_address__protocol), + 26usize => Self(path_secret_map_entry_replaced__peer_address__protocol), + 28usize => Self(unknown_path_secret_packet_sent__peer_address__protocol), + 30usize => Self(unknown_path_secret_packet_received__peer_address__protocol), + 32usize => Self(unknown_path_secret_packet_accepted__peer_address__protocol), + 34usize => Self(unknown_path_secret_packet_rejected__peer_address__protocol), + 36usize => Self(unknown_path_secret_packet_dropped__peer_address__protocol), + 41usize => Self(replay_detected_packet_sent__peer_address__protocol), + 43usize => Self(replay_detected_packet_received__peer_address__protocol), + 45usize => Self(replay_detected_packet_accepted__peer_address__protocol), + 47usize => Self(replay_detected_packet_rejected__peer_address__protocol), + 49usize => Self(replay_detected_packet_dropped__peer_address__protocol), + 51usize => Self(stale_key_packet_sent__peer_address__protocol), + 53usize => Self(stale_key_packet_received__peer_address__protocol), + 55usize => Self(stale_key_packet_accepted__peer_address__protocol), + 57usize => Self(stale_key_packet_rejected__peer_address__protocol), + 59usize => Self(stale_key_packet_dropped__peer_address__protocol), _ => unreachable!("invalid info: {info:?}"), } } @@ -333,7 +333,8 @@ mod measure { 14usize => Self(path_secret_map_initialized__capacity), 16usize => Self(path_secret_map_uninitialized__capacity), 17usize => Self(path_secret_map_uninitialized__entries), - 38usize => Self(replay_potentially_detected__gap), + 18usize => Self(path_secret_map_uninitialized__lifetime), + 39usize => Self(replay_potentially_detected__gap), _ => unreachable!("invalid info: {info:?}"), } } @@ -359,6 +360,8 @@ mod measure { fn path_secret_map_uninitialized__capacity(value: u64); # [link_name = s2n_quic_dc__event__measure__path_secret_map_uninitialized__entries] fn path_secret_map_uninitialized__entries(value: u64); + # [link_name = s2n_quic_dc__event__measure__path_secret_map_uninitialized__lifetime] + fn path_secret_map_uninitialized__lifetime(value: u64); # [link_name = s2n_quic_dc__event__measure__replay_potentially_detected__gap] fn replay_potentially_detected__gap(value: u64); } @@ -395,6 +398,27 @@ mod timer { (self.0)(value.as_duration()); } } + pub mod nominal { + #![allow(non_snake_case)] + use super::*; + use crate::event::metrics::aggregate::Metric; + pub struct Recorder(fn(core::time::Duration, u64, &info::Str)); + impl Recorder { + pub(crate) fn new(info: &'static Info, _variant: &'static info::Variant) -> Self { + unreachable!("invalid info: {info:?}") + } + } + impl NominalRecorder for Recorder { + fn record( + &self, + _info: &'static Info, + variant: &'static info::Variant, + value: T, + ) { + (self.0)(value.as_duration(), variant.id as _, variant.name); + } + } + } } #[derive(Default)] pub struct Registry(()); @@ -405,6 +429,7 @@ impl aggregate::Registry for Registry { type Measure = measure::Recorder; type Gauge = gauge::Recorder; type Timer = timer::Recorder; + type NominalTimer = timer::nominal::Recorder; #[inline] fn register_counter(&self, info: &'static Info) -> Self::Counter { counter::Recorder::new(info) @@ -433,4 +458,12 @@ impl aggregate::Registry for Registry { fn register_timer(&self, info: &'static Info) -> Self::Timer { timer::Recorder::new(info) } + #[inline] + fn register_nominal_timer( + &self, + info: &'static Info, + variant: &'static info::Variant, + ) -> Self::NominalTimer { + timer::nominal::Recorder::new(info, variant) + } } diff --git a/dc/s2n-quic-dc/src/path/secret/map.rs b/dc/s2n-quic-dc/src/path/secret/map.rs index eb488535b3..b2c6b02847 100644 --- a/dc/s2n-quic-dc/src/path/secret/map.rs +++ b/dc/s2n-quic-dc/src/path/secret/map.rs @@ -8,7 +8,7 @@ use crate::{ path::secret::{open, seal, stateless_reset}, stream::TransportFeatures, }; -use s2n_quic_core::dc; +use s2n_quic_core::{dc, time}; use std::{net::SocketAddr, sync::Arc}; mod cleaner; @@ -47,12 +47,17 @@ pub struct Map { } impl Map { - pub fn new( + pub fn new( signer: stateless_reset::Signer, capacity: usize, + clock: C, subscriber: S, - ) -> Self { - let store = state::State::new(signer, capacity, subscriber); + ) -> Self + where + C: 'static + time::Clock + Send + Sync, + S: event::Subscriber, + { + let store = state::State::new(signer, capacity, clock, subscriber); Self { store } } @@ -163,6 +168,7 @@ impl Map { let provider = Self::new( stateless_reset::Signer::random(), peers.len() * 3, + time::NoopClock, event::testing::Subscriber::no_snapshot(), ); let mut secret = [0; 32]; diff --git a/dc/s2n-quic-dc/src/path/secret/map/cleaner.rs b/dc/s2n-quic-dc/src/path/secret/map/cleaner.rs index b47d087426..5178c0895c 100644 --- a/dc/s2n-quic-dc/src/path/secret/map/cleaner.rs +++ b/dc/s2n-quic-dc/src/path/secret/map/cleaner.rs @@ -4,6 +4,7 @@ use super::state::State; use crate::event; use rand::Rng as _; +use s2n_quic_core::time; use std::{ sync::{ atomic::{AtomicBool, AtomicU64, Ordering}, @@ -51,7 +52,11 @@ impl Cleaner { } } - pub fn spawn_thread(&self, state: Arc>) { + pub fn spawn_thread(&self, state: Arc>) + where + C: 'static + time::Clock + Send + Sync, + S: event::Subscriber, + { let state = Arc::downgrade(&state); let handle = std::thread::spawn(move || loop { let Some(state) = state.upgrade() else { @@ -69,7 +74,11 @@ impl Cleaner { } /// Periodic maintenance for various maps. - pub fn clean(&self, state: &State, eviction_cycles: u64) { + pub fn clean(&self, state: &State, eviction_cycles: u64) + where + C: 'static + time::Clock + Send + Sync, + S: event::Subscriber, + { let current_epoch = self.epoch.fetch_add(1, Ordering::Relaxed); let now = Instant::now(); diff --git a/dc/s2n-quic-dc/src/path/secret/map/event_tests.rs b/dc/s2n-quic-dc/src/path/secret/map/event_tests.rs index 2c2fa405db..78031ca94d 100644 --- a/dc/s2n-quic-dc/src/path/secret/map/event_tests.rs +++ b/dc/s2n-quic-dc/src/path/secret/map/event_tests.rs @@ -7,6 +7,7 @@ use crate::{ path::secret::{stateless_reset, Map}, }; use s2n_codec::{DecoderBufferMut, EncoderBuffer}; +use s2n_quic_core::time::NoopClock; use std::sync::Arc; type Subscriber = ( @@ -32,7 +33,7 @@ fn map(capacity: usize) -> Map { fn map_sub(capacity: usize, sub: Arc) -> Map { let signer = stateless_reset::Signer::random(); - Map::new(signer, capacity, sub) + Map::new(signer, capacity, NoopClock, sub) } #[test] diff --git a/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__control_packets__events.snap b/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__control_packets__events.snap index 0a2d46705a..047490ebf2 100644 --- a/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__control_packets__events.snap +++ b/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__control_packets__events.snap @@ -2,37 +2,37 @@ source: quic/s2n-quic-core/src/event/snapshot.rs input_file: dc/s2n-quic-dc/src/path/secret/map/event_tests.rs --- -EndpointMeta PathSecretMapInitialized { capacity: 10 } -EndpointMeta PathSecretMapInitialized { capacity: 10 } -EndpointMeta PathSecretMapEntryInserted { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta PathSecretMapEntryReady { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta PathSecretMapEntryInserted { peer_address: 127.0.0.1:1234, credential_id: "[HIDDEN]" } -EndpointMeta PathSecretMapEntryReady { peer_address: 127.0.0.1:1234, credential_id: "[HIDDEN]" } -EndpointMeta UnknownPathSecretPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta UnknownPathSecretPacketDropped { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta StaleKeyPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta StaleKeyPacketDropped { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta ReplayDetectedPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta ReplayDetectedPacketDropped { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta UnknownPathSecretPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta UnknownPathSecretPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta StaleKeyPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta StaleKeyPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta ReplayDetectedPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta ReplayDetectedPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta UnknownPathSecretPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta UnknownPathSecretPacketAccepted { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta PathSecretMapBackgroundHandshakeRequested { peer_address: 127.0.0.1:5678 } -EndpointMeta StaleKeyPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta StaleKeyPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta ReplayDetectedPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta ReplayDetectedPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta UnknownPathSecretPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta UnknownPathSecretPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta StaleKeyPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta StaleKeyPacketAccepted { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta ReplayDetectedPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } -EndpointMeta ReplayDetectedPacketAccepted { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]", key_id: 123 } -EndpointMeta PathSecretMapBackgroundHandshakeRequested { peer_address: 127.0.0.1:5678 } -EndpointMeta PathSecretMapUninitialized { capacity: 10, entries: 1 } -EndpointMeta PathSecretMapUninitialized { capacity: 10, entries: 1 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapInitialized { capacity: 10 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapInitialized { capacity: 10 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapEntryInserted { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapEntryReady { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapEntryInserted { peer_address: 127.0.0.1:1234, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapEntryReady { peer_address: 127.0.0.1:1234, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } UnknownPathSecretPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } UnknownPathSecretPacketDropped { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } StaleKeyPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } StaleKeyPacketDropped { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } ReplayDetectedPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } ReplayDetectedPacketDropped { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } UnknownPathSecretPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } UnknownPathSecretPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } StaleKeyPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } StaleKeyPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } ReplayDetectedPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } ReplayDetectedPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } UnknownPathSecretPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } UnknownPathSecretPacketAccepted { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapBackgroundHandshakeRequested { peer_address: 127.0.0.1:5678 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } StaleKeyPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } StaleKeyPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } ReplayDetectedPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } ReplayDetectedPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } UnknownPathSecretPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } UnknownPathSecretPacketRejected { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } StaleKeyPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } StaleKeyPacketAccepted { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } ReplayDetectedPacketReceived { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } ReplayDetectedPacketAccepted { peer_address: 127.0.0.1:5678, credential_id: "[HIDDEN]", key_id: 123 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapBackgroundHandshakeRequested { peer_address: 127.0.0.1:5678 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapUninitialized { capacity: 10, entries: 1, lifetime: 1µs } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapUninitialized { capacity: 10, entries: 1, lifetime: 1µs } diff --git a/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__init_uninit__events.snap b/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__init_uninit__events.snap index a5f7749cbe..6e18dcd39f 100644 --- a/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__init_uninit__events.snap +++ b/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__init_uninit__events.snap @@ -2,5 +2,5 @@ source: quic/s2n-quic-core/src/event/snapshot.rs input_file: dc/s2n-quic-dc/src/path/secret/map/event_tests.rs --- -EndpointMeta PathSecretMapInitialized { capacity: 10 } -EndpointMeta PathSecretMapUninitialized { capacity: 10, entries: 0 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapInitialized { capacity: 10 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapUninitialized { capacity: 10, entries: 0, lifetime: 1µs } diff --git a/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__insert_one__events.snap b/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__insert_one__events.snap index 4c0a828c70..a1fb28a3cc 100644 --- a/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__insert_one__events.snap +++ b/dc/s2n-quic-dc/src/path/secret/map/snapshots/path__secret__map__event_tests__insert_one__events.snap @@ -2,7 +2,7 @@ source: quic/s2n-quic-core/src/event/snapshot.rs input_file: dc/s2n-quic-dc/src/path/secret/map/event_tests.rs --- -EndpointMeta PathSecretMapInitialized { capacity: 10 } -EndpointMeta PathSecretMapEntryInserted { peer_address: 127.0.0.1:4567, credential_id: "[HIDDEN]" } -EndpointMeta PathSecretMapEntryReady { peer_address: 127.0.0.1:4567, credential_id: "[HIDDEN]" } -EndpointMeta PathSecretMapUninitialized { capacity: 10, entries: 1 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapInitialized { capacity: 10 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapEntryInserted { peer_address: 127.0.0.1:4567, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapEntryReady { peer_address: 127.0.0.1:4567, credential_id: "[HIDDEN]" } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapUninitialized { capacity: 10, entries: 1, lifetime: 1µs } diff --git a/dc/s2n-quic-dc/src/path/secret/map/state.rs b/dc/s2n-quic-dc/src/path/secret/map/state.rs index 6e3bc490db..175cdfe3e6 100644 --- a/dc/s2n-quic-dc/src/path/secret/map/state.rs +++ b/dc/s2n-quic-dc/src/path/secret/map/state.rs @@ -10,7 +10,10 @@ use crate::{ packet::{secret_control as control, Packet}, path::secret::receiver, }; -use s2n_quic_core::inet::SocketAddress; +use s2n_quic_core::{ + inet::SocketAddress, + time::{self, Timestamp}, +}; use std::{ hash::{BuildHasherDefault, Hasher}, net::{Ipv4Addr, SocketAddr}, @@ -39,7 +42,11 @@ mod tests; // is defined by access to the entry in the map. Unfortunately we lack any good way to authenticate // a peer as *not* having credentials, especially after the peer is gone. It's possible that in the // future information could also come from the TLS provider. -pub(super) struct State { +pub(super) struct State +where + C: 'static + time::Clock + Sync + Send, + S: event::Subscriber, +{ // This is in number of entries. max_capacity: usize, @@ -75,11 +82,24 @@ pub(super) struct State { cleaner: Cleaner, + init_time: Timestamp, + + clock: C, + subscriber: S, } -impl State { - pub fn new(signer: stateless_reset::Signer, capacity: usize, subscriber: S) -> Arc { +impl State +where + C: 'static + time::Clock + Sync + Send, + S: event::Subscriber, +{ + pub fn new( + signer: stateless_reset::Signer, + capacity: usize, + clock: C, + subscriber: S, + ) -> Arc { // FIXME: Avoid unwrap and the whole socket. // // We only ever send on this socket - but we really should be sending on the same @@ -90,6 +110,8 @@ impl State { let control_socket = std::net::UdpSocket::bind((Ipv4Addr::UNSPECIFIED, 0)).unwrap(); control_socket.set_nonblocking(true).unwrap(); + let init_time = clock.get_time(); + let state = Self { // This is around 500MB with current entry size. max_capacity: capacity, @@ -102,6 +124,8 @@ impl State { signer, receiver_shared: receiver::Shared::new(), control_socket, + init_time, + clock, subscriber, }; @@ -296,15 +320,23 @@ impl State { } fn subscriber(&self) -> event::EndpointPublisherSubscriber { + use event::IntoEvent as _; + + let timestamp = self.clock.get_time().into_event(); + event::EndpointPublisherSubscriber::new( - event::builder::EndpointMeta {}, + event::builder::EndpointMeta { timestamp }, None, &self.subscriber, ) } } -impl Store for State { +impl Store for State +where + C: time::Clock + Sync + Send, + S: event::Subscriber, +{ fn secrets_len(&self) -> usize { self.ids.len() } @@ -514,16 +546,26 @@ impl Store for State { } } -impl Drop for State { +impl Drop for State +where + C: 'static + time::Clock + Sync + Send, + S: event::Subscriber, +{ fn drop(&mut self) { if std::thread::panicking() { return; } + let lifetime = self + .clock + .get_time() + .saturating_duration_since(self.init_time); + self.subscriber().on_path_secret_map_uninitialized( event::builder::PathSecretMapUninitialized { capacity: self.secrets_capacity(), entries: self.secrets_len(), + lifetime, }, ); } diff --git a/dc/s2n-quic-dc/src/path/secret/map/state/snapshots/path__secret__map__state__tests__thread_shutdown__events.snap b/dc/s2n-quic-dc/src/path/secret/map/state/snapshots/path__secret__map__state__tests__thread_shutdown__events.snap index 3c57f5302d..16f461ea20 100644 --- a/dc/s2n-quic-dc/src/path/secret/map/state/snapshots/path__secret__map__state__tests__thread_shutdown__events.snap +++ b/dc/s2n-quic-dc/src/path/secret/map/state/snapshots/path__secret__map__state__tests__thread_shutdown__events.snap @@ -2,5 +2,5 @@ source: quic/s2n-quic-core/src/event/snapshot.rs input_file: dc/s2n-quic-dc/src/path/secret/map/state/tests.rs --- -EndpointMeta PathSecretMapInitialized { capacity: 10 } -EndpointMeta PathSecretMapUninitialized { capacity: 10, entries: 0 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapInitialized { capacity: 10 } +EndpointMeta { timestamp: Timestamp(0:00:00.000001) } PathSecretMapUninitialized { capacity: 10, entries: 0, lifetime: 1µs } diff --git a/dc/s2n-quic-dc/src/path/secret/map/state/tests.rs b/dc/s2n-quic-dc/src/path/secret/map/state/tests.rs index 4d321f7dce..5bc4a63a06 100644 --- a/dc/s2n-quic-dc/src/path/secret/map/state/tests.rs +++ b/dc/s2n-quic-dc/src/path/secret/map/state/tests.rs @@ -6,7 +6,7 @@ use crate::{ event::{testing, tracing}, path::secret::{schedule, sender}, }; -use s2n_quic_core::dc; +use s2n_quic_core::{dc, time::NoopClock as Clock}; use std::{ collections::HashSet, fmt, @@ -20,7 +20,7 @@ fn fake_entry(port: u16) -> Arc { #[test] fn cleans_after_delay() { let signer = stateless_reset::Signer::new(b"secret"); - let map = State::new(signer, 50, tracing::Subscriber::default()); + let map = State::new(signer, 50, Clock, tracing::Subscriber::default()); // Stop background processing. We expect to manually invoke clean, and a background worker // might interfere with our state. @@ -51,6 +51,7 @@ fn thread_shutdown() { let map = State::new( signer, 10, + Clock, ( tracing::Subscriber::default(), testing::Subscriber::snapshot(), @@ -123,7 +124,7 @@ enum Invariant { } impl Model { - fn perform(&mut self, operation: Operation, state: &State) { + fn perform(&mut self, operation: Operation, state: &State) { match operation { Operation::Insert { ip, path_secret_id } => { let ip = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::from([0, 0, 0, ip]), 0)); @@ -183,7 +184,7 @@ impl Model { } } - fn check_invariants(&self, state: &State) { + fn check_invariants(&self, state: &State) { for invariant in self.invariants.iter() { // We avoid assertions for contains() if we're running the small capacity test, since // they are likely broken -- we semi-randomly evict peers in that case. @@ -256,7 +257,7 @@ fn check_invariants() { let mut model = Model::default(); let signer = stateless_reset::Signer::new(b"secret"); - let mut map = State::new(signer, 10_000, tracing::Subscriber::default()); + let mut map = State::new(signer, 10_000, Clock, tracing::Subscriber::default()); // Avoid background work interfering with testing. map.cleaner.stop(); @@ -286,7 +287,7 @@ fn check_invariants_no_overflow() { let mut model = Model::default(); let signer = stateless_reset::Signer::new(b"secret"); - let map = State::new(signer, 10_000, tracing::Subscriber::default()); + let map = State::new(signer, 10_000, Clock, tracing::Subscriber::default()); // Avoid background work interfering with testing. map.cleaner.stop(); @@ -309,7 +310,7 @@ fn check_invariants_no_overflow() { #[ignore = "memory growth takes a long time to run"] fn no_memory_growth() { let signer = stateless_reset::Signer::new(b"secret"); - let map = State::new(signer, 100_000, tracing::Subscriber::default()); + let map = State::new(signer, 100_000, Clock, tracing::Subscriber::default()); map.cleaner.stop(); for idx in 0..500_000 { diff --git a/quic/s2n-quic-core/events/connection.rs b/quic/s2n-quic-core/events/connection.rs index 6ab5dc5970..922855eef3 100644 --- a/quic/s2n-quic-core/events/connection.rs +++ b/quic/s2n-quic-core/events/connection.rs @@ -189,6 +189,9 @@ struct KeyUpdate { } #[event("security:key_space_discarded")] +#[checkpoint("initial.latency", |evt| matches!(evt.space, KeySpace::Initial { .. }))] +#[checkpoint("handshake.latency", |evt| matches!(evt.space, KeySpace::Handshake { .. }))] +#[checkpoint("one_rtt.latency", |evt| matches!(evt.space, KeySpace::OneRtt { .. }))] struct KeySpaceDiscarded { #[nominal_counter("space")] space: KeySpace, @@ -204,6 +207,7 @@ struct ConnectionStarted<'a> { #[event("connectivity:connection_closed")] //= https://tools.ietf.org/id/draft-marx-qlog-event-definitions-quic-h3-02#5.1.3 /// Connection closed +#[checkpoint("latency")] struct ConnectionClosed { #[nominal_counter("error")] error: crate::connection::Error, @@ -220,6 +224,7 @@ struct DuplicatePacket<'a> { #[event("transport:transport_parameters_received")] /// Transport parameters received by connection +#[checkpoint("latency")] struct TransportParametersReceived<'a> { transport_parameters: TransportParameters<'a>, } @@ -287,6 +292,9 @@ struct ConnectionMigrationDenied { } #[event("connectivity:handshake_status_updated")] +#[checkpoint("complete.latency", |evt| matches!(evt.status, HandshakeStatus::Complete { .. }))] +#[checkpoint("confirmed.latency", |evt| matches!(evt.status, HandshakeStatus::Confirmed { .. }))] +#[checkpoint("handshake_done_acked.latency", |evt| matches!(evt.status, HandshakeStatus::HandshakeDoneAcked { .. }))] struct HandshakeStatusUpdated { #[nominal_counter("status")] status: HandshakeStatus, @@ -306,11 +314,13 @@ struct PathChallengeUpdated<'a> { } #[event("tls:client_hello")] +#[checkpoint("latency")] struct TlsClientHello<'a> { payload: &'a [&'a [u8]], } #[event("tls:server_hello")] +#[checkpoint("latency")] struct TlsServerHello<'a> { payload: &'a [&'a [u8]], } @@ -353,6 +363,7 @@ struct MtuUpdated { struct SlowStartExited { path_id: u64, #[nominal_counter("cause")] + #[nominal_checkpoint("latency")] cause: SlowStartExitCause, #[measure("congestion_window", Bytes)] congestion_window: u32, @@ -389,6 +400,10 @@ struct BbrStateChanged { #[event("transport:dc_state_changed")] /// The DC state has changed +#[checkpoint("version_negotiated.latency", |evt| matches!(evt.state, DcState::VersionNegotiated { .. }))] +#[checkpoint("no_version_negotiated.latency", |evt| matches!(evt.state, DcState::VersionNegotiated { .. }))] +#[checkpoint("path_secrets.latency", |evt| matches!(evt.state, DcState::PathSecretsReady { .. }))] +#[checkpoint("complete.latency", |evt| matches!(evt.state, DcState::Complete { .. }))] struct DcStateChanged { #[nominal_counter("state")] state: DcState, diff --git a/quic/s2n-quic-core/src/event.rs b/quic/s2n-quic-core/src/event.rs index 38ae36df1a..19e701ea63 100644 --- a/quic/s2n-quic-core/src/event.rs +++ b/quic/s2n-quic-core/src/event.rs @@ -4,7 +4,7 @@ use crate::{connection, endpoint}; #[cfg(feature = "alloc")] use alloc::vec::Vec; -use core::{ops::RangeInclusive, time::Duration}; +use core::{fmt, ops::RangeInclusive, time::Duration}; mod generated; pub mod metrics; @@ -89,9 +89,21 @@ impl IntoEvent> for RangeInclusive { } } -#[derive(Clone, Debug, Copy)] +#[derive(Clone, Copy)] pub struct Timestamp(crate::time::Timestamp); +impl fmt::Debug for Timestamp { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0.fmt(f) + } +} + +impl fmt::Display for Timestamp { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0.fmt(f) + } +} + impl Timestamp { /// The duration since the start of the s2n-quic process. /// @@ -135,6 +147,13 @@ impl IntoEvent for crate::time::Timestamp { } } +impl IntoEvent for Timestamp { + #[inline] + fn into_event(self) -> Timestamp { + self + } +} + #[derive(Clone)] pub struct TlsSession<'a> { session: &'a dyn crate::crypto::tls::TlsSession, diff --git a/quic/s2n-quic-core/src/event/generated/metrics/aggregate.rs b/quic/s2n-quic-core/src/event/generated/metrics/aggregate.rs index a276f5f465..fe0db5fee6 100644 --- a/quic/s2n-quic-core/src/event/generated/metrics/aggregate.rs +++ b/quic/s2n-quic-core/src/event/generated/metrics/aggregate.rs @@ -13,7 +13,7 @@ use crate::event::{ }, }; use alloc::{boxed::Box, vec::Vec}; -static INFO: &[Info; 133usize] = &[ +static INFO: &[Info; 148usize] = &[ info::Builder { id: 0usize, name: Str::new("application_protocol_information\0"), @@ -232,587 +232,682 @@ static INFO: &[Info; 133usize] = &[ .build(), info::Builder { id: 36usize, + name: Str::new("key_space_discarded.initial.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 37usize, + name: Str::new("key_space_discarded.handshake.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 38usize, + name: Str::new("key_space_discarded.one_rtt.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 39usize, name: Str::new("key_space_discarded.space\0"), units: Units::None, } .build(), info::Builder { - id: 37usize, + id: 40usize, name: Str::new("connection_started\0"), units: Units::None, } .build(), info::Builder { - id: 38usize, + id: 41usize, name: Str::new("connection_closed\0"), units: Units::None, } .build(), info::Builder { - id: 39usize, + id: 42usize, + name: Str::new("connection_closed.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 43usize, name: Str::new("connection_closed.error\0"), units: Units::None, } .build(), info::Builder { - id: 40usize, + id: 44usize, name: Str::new("duplicate_packet\0"), units: Units::None, } .build(), info::Builder { - id: 41usize, + id: 45usize, name: Str::new("duplicate_packet.error\0"), units: Units::None, } .build(), info::Builder { - id: 42usize, + id: 46usize, name: Str::new("transport_parameters_received\0"), units: Units::None, } .build(), info::Builder { - id: 43usize, + id: 47usize, + name: Str::new("transport_parameters_received.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 48usize, name: Str::new("datagram_sent\0"), units: Units::None, } .build(), info::Builder { - id: 44usize, + id: 49usize, name: Str::new("datagram_sent.bytes.total\0"), units: Units::Bytes, } .build(), info::Builder { - id: 45usize, + id: 50usize, name: Str::new("datagram_sent.bytes\0"), units: Units::Bytes, } .build(), info::Builder { - id: 46usize, + id: 51usize, name: Str::new("datagram_sent.gso_offset\0"), units: Units::None, } .build(), info::Builder { - id: 47usize, + id: 52usize, name: Str::new("datagram_received\0"), units: Units::None, } .build(), info::Builder { - id: 48usize, + id: 53usize, name: Str::new("datagram_received.bytes.total\0"), units: Units::Bytes, } .build(), info::Builder { - id: 49usize, + id: 54usize, name: Str::new("datagram_received.bytes\0"), units: Units::Bytes, } .build(), info::Builder { - id: 50usize, + id: 55usize, name: Str::new("datagram_dropped\0"), units: Units::None, } .build(), info::Builder { - id: 51usize, + id: 56usize, name: Str::new("datagram_dropped.bytes.total\0"), units: Units::Bytes, } .build(), info::Builder { - id: 52usize, + id: 57usize, name: Str::new("datagram_dropped.bytes\0"), units: Units::Bytes, } .build(), info::Builder { - id: 53usize, + id: 58usize, name: Str::new("datagram_dropped.reason\0"), units: Units::None, } .build(), info::Builder { - id: 54usize, + id: 59usize, name: Str::new("connection_id_updated\0"), units: Units::None, } .build(), info::Builder { - id: 55usize, + id: 60usize, name: Str::new("ecn_state_changed\0"), units: Units::None, } .build(), info::Builder { - id: 56usize, + id: 61usize, name: Str::new("ecn_state_changed.state\0"), units: Units::None, } .build(), info::Builder { - id: 57usize, + id: 62usize, name: Str::new("connection_migration_denied\0"), units: Units::None, } .build(), info::Builder { - id: 58usize, + id: 63usize, name: Str::new("connection_migration_denied.reason\0"), units: Units::None, } .build(), info::Builder { - id: 59usize, + id: 64usize, name: Str::new("handshake_status_updated\0"), units: Units::None, } .build(), info::Builder { - id: 60usize, + id: 65usize, + name: Str::new("handshake_status_updated.complete.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 66usize, + name: Str::new("handshake_status_updated.confirmed.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 67usize, + name: Str::new("handshake_status_updated.handshake_done_acked.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 68usize, name: Str::new("handshake_status_updated.status\0"), units: Units::None, } .build(), info::Builder { - id: 61usize, + id: 69usize, name: Str::new("tls_exporter_ready\0"), units: Units::None, } .build(), info::Builder { - id: 62usize, + id: 70usize, name: Str::new("path_challenge_updated\0"), units: Units::None, } .build(), info::Builder { - id: 63usize, + id: 71usize, name: Str::new("tls_client_hello\0"), units: Units::None, } .build(), info::Builder { - id: 64usize, + id: 72usize, + name: Str::new("tls_client_hello.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 73usize, name: Str::new("tls_server_hello\0"), units: Units::None, } .build(), info::Builder { - id: 65usize, + id: 74usize, + name: Str::new("tls_server_hello.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 75usize, name: Str::new("rx_stream_progress\0"), units: Units::None, } .build(), info::Builder { - id: 66usize, + id: 76usize, name: Str::new("rx_stream_progress.bytes.total\0"), units: Units::Bytes, } .build(), info::Builder { - id: 67usize, + id: 77usize, name: Str::new("rx_stream_progress.bytes\0"), units: Units::Bytes, } .build(), info::Builder { - id: 68usize, + id: 78usize, name: Str::new("tx_stream_progress\0"), units: Units::None, } .build(), info::Builder { - id: 69usize, + id: 79usize, name: Str::new("tx_stream_progress.bytes.total\0"), units: Units::Bytes, } .build(), info::Builder { - id: 70usize, + id: 80usize, name: Str::new("tx_stream_progress.bytes\0"), units: Units::Bytes, } .build(), info::Builder { - id: 71usize, + id: 81usize, name: Str::new("keep_alive_timer_expired\0"), units: Units::None, } .build(), info::Builder { - id: 72usize, + id: 82usize, name: Str::new("mtu_updated\0"), units: Units::None, } .build(), info::Builder { - id: 73usize, + id: 83usize, name: Str::new("mtu_updated.mtu\0"), units: Units::Bytes, } .build(), info::Builder { - id: 74usize, + id: 84usize, name: Str::new("mtu_updated.cause\0"), units: Units::None, } .build(), info::Builder { - id: 75usize, + id: 85usize, name: Str::new("mtu_updated.search_complete\0"), units: Units::None, } .build(), info::Builder { - id: 76usize, + id: 86usize, name: Str::new("slow_start_exited\0"), units: Units::None, } .build(), info::Builder { - id: 77usize, + id: 87usize, name: Str::new("slow_start_exited.cause\0"), units: Units::None, } .build(), info::Builder { - id: 78usize, + id: 88usize, + name: Str::new("slow_start_exited.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 89usize, name: Str::new("slow_start_exited.congestion_window\0"), units: Units::Bytes, } .build(), info::Builder { - id: 79usize, + id: 90usize, name: Str::new("delivery_rate_sampled\0"), units: Units::None, } .build(), info::Builder { - id: 80usize, + id: 91usize, name: Str::new("pacing_rate_updated\0"), units: Units::None, } .build(), info::Builder { - id: 81usize, + id: 92usize, name: Str::new("pacing_rate_updated.bytes_per_second\0"), units: Units::Bytes, } .build(), info::Builder { - id: 82usize, + id: 93usize, name: Str::new("pacing_rate_updated.burst_size\0"), units: Units::Bytes, } .build(), info::Builder { - id: 83usize, + id: 94usize, name: Str::new("pacing_rate_updated.pacing_gain\0"), units: Units::None, } .build(), info::Builder { - id: 84usize, + id: 95usize, name: Str::new("bbr_state_changed\0"), units: Units::None, } .build(), info::Builder { - id: 85usize, + id: 96usize, name: Str::new("bbr_state_changed.state\0"), units: Units::None, } .build(), info::Builder { - id: 86usize, + id: 97usize, name: Str::new("dc_state_changed\0"), units: Units::None, } .build(), info::Builder { - id: 87usize, + id: 98usize, + name: Str::new("dc_state_changed.version_negotiated.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 99usize, + name: Str::new("dc_state_changed.no_version_negotiated.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 100usize, + name: Str::new("dc_state_changed.path_secrets.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 101usize, + name: Str::new("dc_state_changed.complete.latency\0"), + units: Units::Duration, + } + .build(), + info::Builder { + id: 102usize, name: Str::new("dc_state_changed.state\0"), units: Units::None, } .build(), info::Builder { - id: 88usize, + id: 103usize, name: Str::new("version_information\0"), units: Units::None, } .build(), info::Builder { - id: 89usize, + id: 104usize, name: Str::new("endpoint_packet_sent\0"), units: Units::None, } .build(), info::Builder { - id: 90usize, + id: 105usize, name: Str::new("endpoint_packet_received\0"), units: Units::None, } .build(), info::Builder { - id: 91usize, + id: 106usize, name: Str::new("endpoint_datagram_sent\0"), units: Units::None, } .build(), info::Builder { - id: 92usize, + id: 107usize, name: Str::new("endpoint_datagram_sent.bytes\0"), units: Units::Bytes, } .build(), info::Builder { - id: 93usize, + id: 108usize, name: Str::new("endpoint_datagram_sent.bytes.total\0"), units: Units::Bytes, } .build(), info::Builder { - id: 94usize, + id: 109usize, name: Str::new("endpoint_datagram_sent.gso_offset\0"), units: Units::None, } .build(), info::Builder { - id: 95usize, + id: 110usize, name: Str::new("endpoint_datagram_received\0"), units: Units::None, } .build(), info::Builder { - id: 96usize, + id: 111usize, name: Str::new("endpoint_datagram_received.bytes\0"), units: Units::Bytes, } .build(), info::Builder { - id: 97usize, + id: 112usize, name: Str::new("endpoint_datagram_received.bytes.total\0"), units: Units::Bytes, } .build(), info::Builder { - id: 98usize, + id: 113usize, name: Str::new("endpoint_datagram_dropped\0"), units: Units::None, } .build(), info::Builder { - id: 99usize, + id: 114usize, name: Str::new("endpoint_datagram_dropped.bytes\0"), units: Units::Bytes, } .build(), info::Builder { - id: 100usize, + id: 115usize, name: Str::new("endpoint_datagram_dropped.bytes.total\0"), units: Units::Bytes, } .build(), info::Builder { - id: 101usize, + id: 116usize, name: Str::new("endpoint_datagram_dropped.reason\0"), units: Units::None, } .build(), info::Builder { - id: 102usize, + id: 117usize, name: Str::new("endpoint_connection_attempt_failed\0"), units: Units::None, } .build(), info::Builder { - id: 103usize, + id: 118usize, name: Str::new("endpoint_connection_attempt_failed.error\0"), units: Units::None, } .build(), info::Builder { - id: 104usize, + id: 119usize, name: Str::new("platform_tx\0"), units: Units::None, } .build(), info::Builder { - id: 105usize, + id: 120usize, name: Str::new("platform_tx.packets.total\0"), units: Units::None, } .build(), info::Builder { - id: 106usize, + id: 121usize, name: Str::new("platform_tx.packets\0"), units: Units::None, } .build(), info::Builder { - id: 107usize, + id: 122usize, name: Str::new("platform_tx.syscalls.total\0"), units: Units::None, } .build(), info::Builder { - id: 108usize, + id: 123usize, name: Str::new("platform_tx.syscalls\0"), units: Units::None, } .build(), info::Builder { - id: 109usize, + id: 124usize, name: Str::new("platform_tx.syscalls.blocked.total\0"), units: Units::None, } .build(), info::Builder { - id: 110usize, + id: 125usize, name: Str::new("platform_tx.syscalls.blocked\0"), units: Units::None, } .build(), info::Builder { - id: 111usize, + id: 126usize, name: Str::new("platform_tx.errors.total\0"), units: Units::None, } .build(), info::Builder { - id: 112usize, + id: 127usize, name: Str::new("platform_tx.errors\0"), units: Units::None, } .build(), info::Builder { - id: 113usize, + id: 128usize, name: Str::new("platform_tx.errors.dropped.total\0"), units: Units::None, } .build(), info::Builder { - id: 114usize, + id: 129usize, name: Str::new("platform_tx.errors.dropped\0"), units: Units::None, } .build(), info::Builder { - id: 115usize, + id: 130usize, name: Str::new("platform_tx_error\0"), units: Units::None, } .build(), info::Builder { - id: 116usize, + id: 131usize, name: Str::new("platform_rx\0"), units: Units::None, } .build(), info::Builder { - id: 117usize, + id: 132usize, name: Str::new("platform_rx.packets.total\0"), units: Units::None, } .build(), info::Builder { - id: 118usize, + id: 133usize, name: Str::new("platform_rx.packets\0"), units: Units::None, } .build(), info::Builder { - id: 119usize, + id: 134usize, name: Str::new("platform_rx.syscalls.total\0"), units: Units::None, } .build(), info::Builder { - id: 120usize, + id: 135usize, name: Str::new("platform_rx.syscalls\0"), units: Units::None, } .build(), info::Builder { - id: 121usize, + id: 136usize, name: Str::new("platform_rx.syscalls.blocked.total\0"), units: Units::None, } .build(), info::Builder { - id: 122usize, + id: 137usize, name: Str::new("platform_rx.syscalls.blocked\0"), units: Units::None, } .build(), info::Builder { - id: 123usize, + id: 138usize, name: Str::new("platform_rx.errors.total\0"), units: Units::None, } .build(), info::Builder { - id: 124usize, + id: 139usize, name: Str::new("platform_rx.errors\0"), units: Units::None, } .build(), info::Builder { - id: 125usize, + id: 140usize, name: Str::new("platform_rx.errors.dropped.total\0"), units: Units::None, } .build(), info::Builder { - id: 126usize, + id: 141usize, name: Str::new("platform_rx.errors.dropped\0"), units: Units::None, } .build(), info::Builder { - id: 127usize, + id: 142usize, name: Str::new("platform_rx_error\0"), units: Units::None, } .build(), info::Builder { - id: 128usize, + id: 143usize, name: Str::new("platform_feature_configured\0"), units: Units::None, } .build(), info::Builder { - id: 129usize, + id: 144usize, name: Str::new("platform_event_loop_wakeup\0"), units: Units::None, } .build(), info::Builder { - id: 130usize, + id: 145usize, name: Str::new("platform_event_loop_sleep\0"), units: Units::None, } .build(), info::Builder { - id: 131usize, + id: 146usize, name: Str::new("platform_event_loop_sleep.processing_duration\0"), units: Units::Duration, } .build(), info::Builder { - id: 132usize, + id: 147usize, name: Str::new("platform_event_loop_started\0"), units: Units::None, } .build(), ]; +#[derive(Clone, Copy, Debug)] +#[allow(dead_code)] +pub struct ConnectionContext { + start_time: crate::event::Timestamp, +} pub struct Subscriber { #[allow(dead_code)] counters: Box<[R::Counter; 74usize]>, @@ -821,13 +916,17 @@ pub struct Subscriber { #[allow(dead_code)] nominal_counters: Box<[R::NominalCounter]>, #[allow(dead_code)] - nominal_offsets: Box<[usize; 17usize]>, + nominal_counter_offsets: Box<[usize; 17usize]>, #[allow(dead_code)] measures: Box<[R::Measure; 38usize]>, #[allow(dead_code)] gauges: Box<[R::Gauge; 0usize]>, #[allow(dead_code)] - timers: Box<[R::Timer; 1usize]>, + timers: Box<[R::Timer; 15usize]>, + #[allow(dead_code)] + nominal_timers: Box<[R::NominalTimer]>, + #[allow(dead_code)] + nominal_timer_offsets: Box<[usize; 1usize]>, #[allow(dead_code)] registry: R, } @@ -848,11 +947,13 @@ impl Subscriber { pub fn new(registry: R) -> Self { let mut counters = Vec::with_capacity(74usize); let mut bool_counters = Vec::with_capacity(3usize); - let mut nominal_offsets = Vec::with_capacity(17usize); let mut nominal_counters = Vec::with_capacity(17usize); + let mut nominal_counter_offsets = Vec::with_capacity(17usize); let mut measures = Vec::with_capacity(38usize); let mut gauges = Vec::with_capacity(0usize); - let mut timers = Vec::with_capacity(1usize); + let mut timers = Vec::with_capacity(15usize); + let mut nominal_timers = Vec::with_capacity(1usize); + let mut nominal_timer_offsets = Vec::with_capacity(1usize); counters.push(registry.register_counter(&INFO[0usize])); counters.push(registry.register_counter(&INFO[1usize])); counters.push(registry.register_counter(&INFO[2usize])); @@ -873,63 +974,63 @@ impl Subscriber { counters.push(registry.register_counter(&INFO[32usize])); counters.push(registry.register_counter(&INFO[34usize])); counters.push(registry.register_counter(&INFO[35usize])); - counters.push(registry.register_counter(&INFO[37usize])); - counters.push(registry.register_counter(&INFO[38usize])); counters.push(registry.register_counter(&INFO[40usize])); - counters.push(registry.register_counter(&INFO[42usize])); - counters.push(registry.register_counter(&INFO[43usize])); + counters.push(registry.register_counter(&INFO[41usize])); counters.push(registry.register_counter(&INFO[44usize])); - counters.push(registry.register_counter(&INFO[47usize])); + counters.push(registry.register_counter(&INFO[46usize])); counters.push(registry.register_counter(&INFO[48usize])); - counters.push(registry.register_counter(&INFO[50usize])); - counters.push(registry.register_counter(&INFO[51usize])); - counters.push(registry.register_counter(&INFO[54usize])); + counters.push(registry.register_counter(&INFO[49usize])); + counters.push(registry.register_counter(&INFO[52usize])); + counters.push(registry.register_counter(&INFO[53usize])); counters.push(registry.register_counter(&INFO[55usize])); - counters.push(registry.register_counter(&INFO[57usize])); + counters.push(registry.register_counter(&INFO[56usize])); counters.push(registry.register_counter(&INFO[59usize])); - counters.push(registry.register_counter(&INFO[61usize])); + counters.push(registry.register_counter(&INFO[60usize])); counters.push(registry.register_counter(&INFO[62usize])); - counters.push(registry.register_counter(&INFO[63usize])); counters.push(registry.register_counter(&INFO[64usize])); - counters.push(registry.register_counter(&INFO[65usize])); - counters.push(registry.register_counter(&INFO[66usize])); - counters.push(registry.register_counter(&INFO[68usize])); counters.push(registry.register_counter(&INFO[69usize])); + counters.push(registry.register_counter(&INFO[70usize])); counters.push(registry.register_counter(&INFO[71usize])); - counters.push(registry.register_counter(&INFO[72usize])); + counters.push(registry.register_counter(&INFO[73usize])); + counters.push(registry.register_counter(&INFO[75usize])); counters.push(registry.register_counter(&INFO[76usize])); + counters.push(registry.register_counter(&INFO[78usize])); counters.push(registry.register_counter(&INFO[79usize])); - counters.push(registry.register_counter(&INFO[80usize])); - counters.push(registry.register_counter(&INFO[84usize])); + counters.push(registry.register_counter(&INFO[81usize])); + counters.push(registry.register_counter(&INFO[82usize])); counters.push(registry.register_counter(&INFO[86usize])); - counters.push(registry.register_counter(&INFO[88usize])); - counters.push(registry.register_counter(&INFO[89usize])); counters.push(registry.register_counter(&INFO[90usize])); counters.push(registry.register_counter(&INFO[91usize])); counters.push(registry.register_counter(&INFO[95usize])); - counters.push(registry.register_counter(&INFO[98usize])); - counters.push(registry.register_counter(&INFO[102usize])); + counters.push(registry.register_counter(&INFO[97usize])); + counters.push(registry.register_counter(&INFO[103usize])); counters.push(registry.register_counter(&INFO[104usize])); counters.push(registry.register_counter(&INFO[105usize])); - counters.push(registry.register_counter(&INFO[107usize])); - counters.push(registry.register_counter(&INFO[109usize])); - counters.push(registry.register_counter(&INFO[111usize])); + counters.push(registry.register_counter(&INFO[106usize])); + counters.push(registry.register_counter(&INFO[110usize])); counters.push(registry.register_counter(&INFO[113usize])); - counters.push(registry.register_counter(&INFO[115usize])); - counters.push(registry.register_counter(&INFO[116usize])); counters.push(registry.register_counter(&INFO[117usize])); counters.push(registry.register_counter(&INFO[119usize])); - counters.push(registry.register_counter(&INFO[121usize])); - counters.push(registry.register_counter(&INFO[123usize])); - counters.push(registry.register_counter(&INFO[125usize])); - counters.push(registry.register_counter(&INFO[127usize])); + counters.push(registry.register_counter(&INFO[120usize])); + counters.push(registry.register_counter(&INFO[122usize])); + counters.push(registry.register_counter(&INFO[124usize])); + counters.push(registry.register_counter(&INFO[126usize])); counters.push(registry.register_counter(&INFO[128usize])); - counters.push(registry.register_counter(&INFO[129usize])); counters.push(registry.register_counter(&INFO[130usize])); + counters.push(registry.register_counter(&INFO[131usize])); counters.push(registry.register_counter(&INFO[132usize])); + counters.push(registry.register_counter(&INFO[134usize])); + counters.push(registry.register_counter(&INFO[136usize])); + counters.push(registry.register_counter(&INFO[138usize])); + counters.push(registry.register_counter(&INFO[140usize])); + counters.push(registry.register_counter(&INFO[142usize])); + counters.push(registry.register_counter(&INFO[143usize])); + counters.push(registry.register_counter(&INFO[144usize])); + counters.push(registry.register_counter(&INFO[145usize])); + counters.push(registry.register_counter(&INFO[147usize])); bool_counters.push(registry.register_bool_counter(&INFO[16usize])); bool_counters.push(registry.register_bool_counter(&INFO[26usize])); - bool_counters.push(registry.register_bool_counter(&INFO[75usize])); + bool_counters.push(registry.register_bool_counter(&INFO[85usize])); { #[allow(unused_imports)] use api::*; @@ -942,7 +1043,7 @@ impl Subscriber { count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); @@ -953,7 +1054,7 @@ impl Subscriber { count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); @@ -964,7 +1065,7 @@ impl Subscriber { count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); @@ -975,150 +1076,150 @@ impl Subscriber { count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[36usize], variant)); + .push(registry.register_nominal_counter(&INFO[39usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[39usize], variant)); + .push(registry.register_nominal_counter(&INFO[43usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[41usize], variant)); + .push(registry.register_nominal_counter(&INFO[45usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[53usize], variant)); + .push(registry.register_nominal_counter(&INFO[58usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[56usize], variant)); + .push(registry.register_nominal_counter(&INFO[61usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[58usize], variant)); + .push(registry.register_nominal_counter(&INFO[63usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[60usize], variant)); + .push(registry.register_nominal_counter(&INFO[68usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[74usize], variant)); + .push(registry.register_nominal_counter(&INFO[84usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[77usize], variant)); + .push(registry.register_nominal_counter(&INFO[87usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[85usize], variant)); + .push(registry.register_nominal_counter(&INFO[96usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[87usize], variant)); + .push(registry.register_nominal_counter(&INFO[102usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[101usize], variant)); + .push(registry.register_nominal_counter(&INFO[116usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } { let offset = nominal_counters.len(); let mut count = 0; for variant in ::VARIANTS.iter() { nominal_counters - .push(registry.register_nominal_counter(&INFO[103usize], variant)); + .push(registry.register_nominal_counter(&INFO[118usize], variant)); count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - nominal_offsets.push(offset); + nominal_counter_offsets.push(offset); } } measures.push(registry.register_measure(&INFO[5usize])); @@ -1131,35 +1232,63 @@ impl Subscriber { measures.push(registry.register_measure(&INFO[23usize])); measures.push(registry.register_measure(&INFO[24usize])); measures.push(registry.register_measure(&INFO[25usize])); - measures.push(registry.register_measure(&INFO[45usize])); - measures.push(registry.register_measure(&INFO[46usize])); - measures.push(registry.register_measure(&INFO[49usize])); - measures.push(registry.register_measure(&INFO[52usize])); - measures.push(registry.register_measure(&INFO[67usize])); - measures.push(registry.register_measure(&INFO[70usize])); - measures.push(registry.register_measure(&INFO[73usize])); - measures.push(registry.register_measure(&INFO[78usize])); - measures.push(registry.register_measure(&INFO[81usize])); - measures.push(registry.register_measure(&INFO[82usize])); + measures.push(registry.register_measure(&INFO[50usize])); + measures.push(registry.register_measure(&INFO[51usize])); + measures.push(registry.register_measure(&INFO[54usize])); + measures.push(registry.register_measure(&INFO[57usize])); + measures.push(registry.register_measure(&INFO[77usize])); + measures.push(registry.register_measure(&INFO[80usize])); measures.push(registry.register_measure(&INFO[83usize])); + measures.push(registry.register_measure(&INFO[89usize])); measures.push(registry.register_measure(&INFO[92usize])); measures.push(registry.register_measure(&INFO[93usize])); measures.push(registry.register_measure(&INFO[94usize])); - measures.push(registry.register_measure(&INFO[96usize])); - measures.push(registry.register_measure(&INFO[97usize])); - measures.push(registry.register_measure(&INFO[99usize])); - measures.push(registry.register_measure(&INFO[100usize])); - measures.push(registry.register_measure(&INFO[106usize])); + measures.push(registry.register_measure(&INFO[107usize])); measures.push(registry.register_measure(&INFO[108usize])); - measures.push(registry.register_measure(&INFO[110usize])); + measures.push(registry.register_measure(&INFO[109usize])); + measures.push(registry.register_measure(&INFO[111usize])); measures.push(registry.register_measure(&INFO[112usize])); measures.push(registry.register_measure(&INFO[114usize])); - measures.push(registry.register_measure(&INFO[118usize])); - measures.push(registry.register_measure(&INFO[120usize])); - measures.push(registry.register_measure(&INFO[122usize])); - measures.push(registry.register_measure(&INFO[124usize])); - measures.push(registry.register_measure(&INFO[126usize])); - timers.push(registry.register_timer(&INFO[131usize])); + measures.push(registry.register_measure(&INFO[115usize])); + measures.push(registry.register_measure(&INFO[121usize])); + measures.push(registry.register_measure(&INFO[123usize])); + measures.push(registry.register_measure(&INFO[125usize])); + measures.push(registry.register_measure(&INFO[127usize])); + measures.push(registry.register_measure(&INFO[129usize])); + measures.push(registry.register_measure(&INFO[133usize])); + measures.push(registry.register_measure(&INFO[135usize])); + measures.push(registry.register_measure(&INFO[137usize])); + measures.push(registry.register_measure(&INFO[139usize])); + measures.push(registry.register_measure(&INFO[141usize])); + timers.push(registry.register_timer(&INFO[36usize])); + timers.push(registry.register_timer(&INFO[37usize])); + timers.push(registry.register_timer(&INFO[38usize])); + timers.push(registry.register_timer(&INFO[42usize])); + timers.push(registry.register_timer(&INFO[47usize])); + timers.push(registry.register_timer(&INFO[65usize])); + timers.push(registry.register_timer(&INFO[66usize])); + timers.push(registry.register_timer(&INFO[67usize])); + timers.push(registry.register_timer(&INFO[72usize])); + timers.push(registry.register_timer(&INFO[74usize])); + timers.push(registry.register_timer(&INFO[98usize])); + timers.push(registry.register_timer(&INFO[99usize])); + timers.push(registry.register_timer(&INFO[100usize])); + timers.push(registry.register_timer(&INFO[101usize])); + timers.push(registry.register_timer(&INFO[146usize])); + { + #[allow(unused_imports)] + use api::*; + { + let offset = nominal_timers.len(); + let mut count = 0; + for variant in ::VARIANTS.iter() { + nominal_timers.push(registry.register_nominal_timer(&INFO[88usize], variant)); + count += 1; + } + debug_assert_ne!(count, 0, "field type needs at least one variant"); + nominal_timer_offsets.push(offset); + } + } Self { counters: counters .try_into() @@ -1168,7 +1297,7 @@ impl Subscriber { .try_into() .unwrap_or_else(|_| panic!("invalid len")), nominal_counters: nominal_counters.into(), - nominal_offsets: nominal_offsets + nominal_counter_offsets: nominal_counter_offsets .try_into() .unwrap_or_else(|_| panic!("invalid len")), measures: measures @@ -1176,6 +1305,10 @@ impl Subscriber { .unwrap_or_else(|_| panic!("invalid len")), gauges: gauges.try_into().unwrap_or_else(|_| panic!("invalid len")), timers: timers.try_into().unwrap_or_else(|_| panic!("invalid len")), + nominal_timers: nominal_timers.into(), + nominal_timer_offsets: nominal_timer_offsets + .try_into() + .unwrap_or_else(|_| panic!("invalid len")), registry, } } @@ -1206,60 +1339,60 @@ impl Subscriber { 17usize => (&INFO[32usize], entry), 18usize => (&INFO[34usize], entry), 19usize => (&INFO[35usize], entry), - 20usize => (&INFO[37usize], entry), - 21usize => (&INFO[38usize], entry), - 22usize => (&INFO[40usize], entry), - 23usize => (&INFO[42usize], entry), - 24usize => (&INFO[43usize], entry), - 25usize => (&INFO[44usize], entry), - 26usize => (&INFO[47usize], entry), - 27usize => (&INFO[48usize], entry), - 28usize => (&INFO[50usize], entry), - 29usize => (&INFO[51usize], entry), - 30usize => (&INFO[54usize], entry), - 31usize => (&INFO[55usize], entry), - 32usize => (&INFO[57usize], entry), - 33usize => (&INFO[59usize], entry), - 34usize => (&INFO[61usize], entry), - 35usize => (&INFO[62usize], entry), - 36usize => (&INFO[63usize], entry), - 37usize => (&INFO[64usize], entry), - 38usize => (&INFO[65usize], entry), - 39usize => (&INFO[66usize], entry), - 40usize => (&INFO[68usize], entry), - 41usize => (&INFO[69usize], entry), - 42usize => (&INFO[71usize], entry), - 43usize => (&INFO[72usize], entry), - 44usize => (&INFO[76usize], entry), - 45usize => (&INFO[79usize], entry), - 46usize => (&INFO[80usize], entry), - 47usize => (&INFO[84usize], entry), - 48usize => (&INFO[86usize], entry), - 49usize => (&INFO[88usize], entry), - 50usize => (&INFO[89usize], entry), - 51usize => (&INFO[90usize], entry), - 52usize => (&INFO[91usize], entry), - 53usize => (&INFO[95usize], entry), - 54usize => (&INFO[98usize], entry), - 55usize => (&INFO[102usize], entry), - 56usize => (&INFO[104usize], entry), - 57usize => (&INFO[105usize], entry), - 58usize => (&INFO[107usize], entry), - 59usize => (&INFO[109usize], entry), - 60usize => (&INFO[111usize], entry), - 61usize => (&INFO[113usize], entry), - 62usize => (&INFO[115usize], entry), - 63usize => (&INFO[116usize], entry), - 64usize => (&INFO[117usize], entry), - 65usize => (&INFO[119usize], entry), - 66usize => (&INFO[121usize], entry), - 67usize => (&INFO[123usize], entry), - 68usize => (&INFO[125usize], entry), - 69usize => (&INFO[127usize], entry), - 70usize => (&INFO[128usize], entry), - 71usize => (&INFO[129usize], entry), - 72usize => (&INFO[130usize], entry), - 73usize => (&INFO[132usize], entry), + 20usize => (&INFO[40usize], entry), + 21usize => (&INFO[41usize], entry), + 22usize => (&INFO[44usize], entry), + 23usize => (&INFO[46usize], entry), + 24usize => (&INFO[48usize], entry), + 25usize => (&INFO[49usize], entry), + 26usize => (&INFO[52usize], entry), + 27usize => (&INFO[53usize], entry), + 28usize => (&INFO[55usize], entry), + 29usize => (&INFO[56usize], entry), + 30usize => (&INFO[59usize], entry), + 31usize => (&INFO[60usize], entry), + 32usize => (&INFO[62usize], entry), + 33usize => (&INFO[64usize], entry), + 34usize => (&INFO[69usize], entry), + 35usize => (&INFO[70usize], entry), + 36usize => (&INFO[71usize], entry), + 37usize => (&INFO[73usize], entry), + 38usize => (&INFO[75usize], entry), + 39usize => (&INFO[76usize], entry), + 40usize => (&INFO[78usize], entry), + 41usize => (&INFO[79usize], entry), + 42usize => (&INFO[81usize], entry), + 43usize => (&INFO[82usize], entry), + 44usize => (&INFO[86usize], entry), + 45usize => (&INFO[90usize], entry), + 46usize => (&INFO[91usize], entry), + 47usize => (&INFO[95usize], entry), + 48usize => (&INFO[97usize], entry), + 49usize => (&INFO[103usize], entry), + 50usize => (&INFO[104usize], entry), + 51usize => (&INFO[105usize], entry), + 52usize => (&INFO[106usize], entry), + 53usize => (&INFO[110usize], entry), + 54usize => (&INFO[113usize], entry), + 55usize => (&INFO[117usize], entry), + 56usize => (&INFO[119usize], entry), + 57usize => (&INFO[120usize], entry), + 58usize => (&INFO[122usize], entry), + 59usize => (&INFO[124usize], entry), + 60usize => (&INFO[126usize], entry), + 61usize => (&INFO[128usize], entry), + 62usize => (&INFO[130usize], entry), + 63usize => (&INFO[131usize], entry), + 64usize => (&INFO[132usize], entry), + 65usize => (&INFO[134usize], entry), + 66usize => (&INFO[136usize], entry), + 67usize => (&INFO[138usize], entry), + 68usize => (&INFO[140usize], entry), + 69usize => (&INFO[142usize], entry), + 70usize => (&INFO[143usize], entry), + 71usize => (&INFO[144usize], entry), + 72usize => (&INFO[145usize], entry), + 73usize => (&INFO[147usize], entry), _ => unsafe { core::hint::unreachable_unchecked() }, }) } @@ -1279,7 +1412,7 @@ impl Subscriber { .map(|(idx, entry)| match idx { 0usize => (&INFO[16usize], entry), 1usize => (&INFO[26usize], entry), - 2usize => (&INFO[75usize], entry), + 2usize => (&INFO[85usize], entry), _ => unsafe { core::hint::unreachable_unchecked() }, }) } @@ -1296,7 +1429,7 @@ impl Subscriber { &self, ) -> impl Iterator + '_ { use api::*; - self.nominal_offsets + self.nominal_counter_offsets .iter() .enumerate() .map(|(idx, entry)| match idx { @@ -1328,79 +1461,79 @@ impl Subscriber { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[36usize], entries, variants) + (&INFO[39usize], entries, variants) } 5usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[39usize], entries, variants) + (&INFO[43usize], entries, variants) } 6usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[41usize], entries, variants) + (&INFO[45usize], entries, variants) } 7usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[53usize], entries, variants) + (&INFO[58usize], entries, variants) } 8usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[56usize], entries, variants) + (&INFO[61usize], entries, variants) } 9usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[58usize], entries, variants) + (&INFO[63usize], entries, variants) } 10usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[60usize], entries, variants) + (&INFO[68usize], entries, variants) } 11usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[74usize], entries, variants) + (&INFO[84usize], entries, variants) } 12usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[77usize], entries, variants) + (&INFO[87usize], entries, variants) } 13usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[85usize], entries, variants) + (&INFO[96usize], entries, variants) } 14usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[87usize], entries, variants) + (&INFO[102usize], entries, variants) } 15usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[101usize], entries, variants) + (&INFO[116usize], entries, variants) } 16usize => { let offset = *entry; let variants = ::VARIANTS; let entries = &self.nominal_counters[offset..offset + variants.len()]; - (&INFO[103usize], entries, variants) + (&INFO[118usize], entries, variants) } _ => unsafe { core::hint::unreachable_unchecked() }, }) @@ -1409,7 +1542,7 @@ impl Subscriber { #[inline(always)] fn count_nominal(&self, info: usize, id: usize, value: &T) { let info = &INFO[info]; - let idx = self.nominal_offsets[id] + value.variant_idx(); + let idx = self.nominal_counter_offsets[id] + value.variant_idx(); let counter = &self.nominal_counters[idx]; counter.record(info, value.as_variant(), 1usize); } @@ -1430,34 +1563,34 @@ impl Subscriber { 7usize => (&INFO[23usize], entry), 8usize => (&INFO[24usize], entry), 9usize => (&INFO[25usize], entry), - 10usize => (&INFO[45usize], entry), - 11usize => (&INFO[46usize], entry), - 12usize => (&INFO[49usize], entry), - 13usize => (&INFO[52usize], entry), - 14usize => (&INFO[67usize], entry), - 15usize => (&INFO[70usize], entry), - 16usize => (&INFO[73usize], entry), - 17usize => (&INFO[78usize], entry), - 18usize => (&INFO[81usize], entry), - 19usize => (&INFO[82usize], entry), - 20usize => (&INFO[83usize], entry), - 21usize => (&INFO[92usize], entry), - 22usize => (&INFO[93usize], entry), - 23usize => (&INFO[94usize], entry), - 24usize => (&INFO[96usize], entry), - 25usize => (&INFO[97usize], entry), - 26usize => (&INFO[99usize], entry), - 27usize => (&INFO[100usize], entry), - 28usize => (&INFO[106usize], entry), - 29usize => (&INFO[108usize], entry), - 30usize => (&INFO[110usize], entry), - 31usize => (&INFO[112usize], entry), - 32usize => (&INFO[114usize], entry), - 33usize => (&INFO[118usize], entry), - 34usize => (&INFO[120usize], entry), - 35usize => (&INFO[122usize], entry), - 36usize => (&INFO[124usize], entry), - 37usize => (&INFO[126usize], entry), + 10usize => (&INFO[50usize], entry), + 11usize => (&INFO[51usize], entry), + 12usize => (&INFO[54usize], entry), + 13usize => (&INFO[57usize], entry), + 14usize => (&INFO[77usize], entry), + 15usize => (&INFO[80usize], entry), + 16usize => (&INFO[83usize], entry), + 17usize => (&INFO[89usize], entry), + 18usize => (&INFO[92usize], entry), + 19usize => (&INFO[93usize], entry), + 20usize => (&INFO[94usize], entry), + 21usize => (&INFO[107usize], entry), + 22usize => (&INFO[108usize], entry), + 23usize => (&INFO[109usize], entry), + 24usize => (&INFO[111usize], entry), + 25usize => (&INFO[112usize], entry), + 26usize => (&INFO[114usize], entry), + 27usize => (&INFO[115usize], entry), + 28usize => (&INFO[121usize], entry), + 29usize => (&INFO[123usize], entry), + 30usize => (&INFO[125usize], entry), + 31usize => (&INFO[127usize], entry), + 32usize => (&INFO[129usize], entry), + 33usize => (&INFO[133usize], entry), + 34usize => (&INFO[135usize], entry), + 35usize => (&INFO[137usize], entry), + 36usize => (&INFO[139usize], entry), + 37usize => (&INFO[141usize], entry), _ => unsafe { core::hint::unreachable_unchecked() }, }) } @@ -1487,7 +1620,21 @@ impl Subscriber { .iter() .enumerate() .map(|(idx, entry)| match idx { - 0usize => (&INFO[131usize], entry), + 0usize => (&INFO[36usize], entry), + 1usize => (&INFO[37usize], entry), + 2usize => (&INFO[38usize], entry), + 3usize => (&INFO[42usize], entry), + 4usize => (&INFO[47usize], entry), + 5usize => (&INFO[65usize], entry), + 6usize => (&INFO[66usize], entry), + 7usize => (&INFO[67usize], entry), + 8usize => (&INFO[72usize], entry), + 9usize => (&INFO[74usize], entry), + 10usize => (&INFO[98usize], entry), + 11usize => (&INFO[99usize], entry), + 12usize => (&INFO[100usize], entry), + 13usize => (&INFO[101usize], entry), + 14usize => (&INFO[146usize], entry), _ => unsafe { core::hint::unreachable_unchecked() }, }) } @@ -1498,14 +1645,31 @@ impl Subscriber { let timer = &self.timers[id]; timer.record(info, value); } + #[allow(dead_code)] + #[inline(always)] + fn time_nominal( + &self, + info: usize, + id: usize, + value: &T, + duration: core::time::Duration, + ) { + let info = &INFO[info]; + let idx = self.nominal_timer_offsets[id] + value.variant_idx(); + let counter = &self.nominal_timers[idx]; + counter.record(info, value.as_variant(), duration); + } } impl event::Subscriber for Subscriber { - type ConnectionContext = (); + type ConnectionContext = ConnectionContext; fn create_connection_context( &mut self, - _meta: &api::ConnectionMeta, + meta: &api::ConnectionMeta, _info: &api::ConnectionInfo, ) -> Self::ConnectionContext { + Self::ConnectionContext { + start_time: meta.timestamp, + } } #[inline] fn on_application_protocol_information( @@ -1514,6 +1678,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::ApplicationProtocolInformation, ) { + #[allow(unused_imports)] + use api::*; self.count(0usize, 0usize, 1usize); let _ = context; let _ = meta; @@ -1526,6 +1692,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::ServerNameInformation, ) { + #[allow(unused_imports)] + use api::*; self.count(1usize, 1usize, 1usize); let _ = context; let _ = meta; @@ -1538,6 +1706,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::PacketSkipped, ) { + #[allow(unused_imports)] + use api::*; self.count(2usize, 2usize, 1usize); let _ = context; let _ = meta; @@ -1550,6 +1720,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::PacketSent, ) { + #[allow(unused_imports)] + use api::*; self.count(3usize, 3usize, 1usize); self.count(4usize, 4usize, event.packet_len); self.measure(5usize, 0usize, event.packet_len); @@ -1564,6 +1736,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::PacketReceived, ) { + #[allow(unused_imports)] + use api::*; self.count(6usize, 5usize, 1usize); let _ = context; let _ = meta; @@ -1576,6 +1750,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::ActivePathUpdated, ) { + #[allow(unused_imports)] + use api::*; self.count(7usize, 6usize, 1usize); let _ = context; let _ = meta; @@ -1588,6 +1764,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::PathCreated, ) { + #[allow(unused_imports)] + use api::*; self.count(8usize, 7usize, 1usize); let _ = context; let _ = meta; @@ -1600,6 +1778,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::FrameSent, ) { + #[allow(unused_imports)] + use api::*; self.count(9usize, 8usize, 1usize); self.count_nominal(10usize, 0usize, &event.frame); let _ = context; @@ -1613,6 +1793,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::FrameReceived, ) { + #[allow(unused_imports)] + use api::*; self.count(11usize, 9usize, 1usize); self.count_nominal(12usize, 1usize, &event.frame); let _ = context; @@ -1626,6 +1808,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::PacketLost, ) { + #[allow(unused_imports)] + use api::*; self.count(13usize, 10usize, 1usize); self.count(14usize, 11usize, event.bytes_lost); self.measure(15usize, 1usize, event.bytes_lost); @@ -1641,6 +1825,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::RecoveryMetrics, ) { + #[allow(unused_imports)] + use api::*; self.count(17usize, 12usize, 1usize); self.measure(18usize, 2usize, event.min_rtt); self.measure(19usize, 3usize, event.smoothed_rtt); @@ -1662,6 +1848,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::Congestion, ) { + #[allow(unused_imports)] + use api::*; self.count(27usize, 13usize, 1usize); self.count_nominal(28usize, 2usize, &event.source); let _ = context; @@ -1675,6 +1863,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::RxAckRangeDropped, ) { + #[allow(unused_imports)] + use api::*; self.count(29usize, 14usize, 1usize); let _ = context; let _ = meta; @@ -1687,6 +1877,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::AckRangeReceived, ) { + #[allow(unused_imports)] + use api::*; self.count(30usize, 15usize, 1usize); let _ = context; let _ = meta; @@ -1699,6 +1891,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::AckRangeSent, ) { + #[allow(unused_imports)] + use api::*; self.count(31usize, 16usize, 1usize); let _ = context; let _ = meta; @@ -1711,6 +1905,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::PacketDropped, ) { + #[allow(unused_imports)] + use api::*; self.count(32usize, 17usize, 1usize); self.count_nominal(33usize, 3usize, &event.reason); let _ = context; @@ -1724,6 +1920,8 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::KeyUpdate, ) { + #[allow(unused_imports)] + use api::*; self.count(34usize, 18usize, 1usize); let _ = context; let _ = meta; @@ -1736,8 +1934,46 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::KeySpaceDiscarded, ) { + #[allow(unused_imports)] + use api::*; self.count(35usize, 19usize, 1usize); - self.count_nominal(36usize, 4usize, &event.space); + { + fn check(evt: &api::KeySpaceDiscarded) -> bool { + matches!(evt.space, KeySpace::Initial { .. }) + } + if check(event) { + self.time( + 36usize, + 0usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); + } + } + { + fn check(evt: &api::KeySpaceDiscarded) -> bool { + matches!(evt.space, KeySpace::Handshake { .. }) + } + if check(event) { + self.time( + 37usize, + 1usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); + } + } + { + fn check(evt: &api::KeySpaceDiscarded) -> bool { + matches!(evt.space, KeySpace::OneRtt { .. }) + } + if check(event) { + self.time( + 38usize, + 2usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); + } + } + self.count_nominal(39usize, 4usize, &event.space); let _ = context; let _ = meta; let _ = event; @@ -1749,7 +1985,9 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::ConnectionStarted, ) { - self.count(37usize, 20usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(40usize, 20usize, 1usize); let _ = context; let _ = meta; let _ = event; @@ -1761,8 +1999,15 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::ConnectionClosed, ) { - self.count(38usize, 21usize, 1usize); - self.count_nominal(39usize, 5usize, &event.error); + #[allow(unused_imports)] + use api::*; + self.count(41usize, 21usize, 1usize); + self.time( + 42usize, + 3usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); + self.count_nominal(43usize, 5usize, &event.error); let _ = context; let _ = meta; let _ = event; @@ -1774,8 +2019,10 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::DuplicatePacket, ) { - self.count(40usize, 22usize, 1usize); - self.count_nominal(41usize, 6usize, &event.error); + #[allow(unused_imports)] + use api::*; + self.count(44usize, 22usize, 1usize); + self.count_nominal(45usize, 6usize, &event.error); let _ = context; let _ = meta; let _ = event; @@ -1787,7 +2034,14 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::TransportParametersReceived, ) { - self.count(42usize, 23usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(46usize, 23usize, 1usize); + self.time( + 47usize, + 4usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); let _ = context; let _ = meta; let _ = event; @@ -1799,10 +2053,12 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::DatagramSent, ) { - self.count(43usize, 24usize, 1usize); - self.count(44usize, 25usize, event.len); - self.measure(45usize, 10usize, event.len); - self.measure(46usize, 11usize, event.gso_offset); + #[allow(unused_imports)] + use api::*; + self.count(48usize, 24usize, 1usize); + self.count(49usize, 25usize, event.len); + self.measure(50usize, 10usize, event.len); + self.measure(51usize, 11usize, event.gso_offset); let _ = context; let _ = meta; let _ = event; @@ -1814,9 +2070,11 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::DatagramReceived, ) { - self.count(47usize, 26usize, 1usize); - self.count(48usize, 27usize, event.len); - self.measure(49usize, 12usize, event.len); + #[allow(unused_imports)] + use api::*; + self.count(52usize, 26usize, 1usize); + self.count(53usize, 27usize, event.len); + self.measure(54usize, 12usize, event.len); let _ = context; let _ = meta; let _ = event; @@ -1828,10 +2086,12 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::DatagramDropped, ) { - self.count(50usize, 28usize, 1usize); - self.count(51usize, 29usize, event.len); - self.measure(52usize, 13usize, event.len); - self.count_nominal(53usize, 7usize, &event.reason); + #[allow(unused_imports)] + use api::*; + self.count(55usize, 28usize, 1usize); + self.count(56usize, 29usize, event.len); + self.measure(57usize, 13usize, event.len); + self.count_nominal(58usize, 7usize, &event.reason); let _ = context; let _ = meta; let _ = event; @@ -1843,7 +2103,9 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::ConnectionIdUpdated, ) { - self.count(54usize, 30usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(59usize, 30usize, 1usize); let _ = context; let _ = meta; let _ = event; @@ -1855,8 +2117,10 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::EcnStateChanged, ) { - self.count(55usize, 31usize, 1usize); - self.count_nominal(56usize, 8usize, &event.state); + #[allow(unused_imports)] + use api::*; + self.count(60usize, 31usize, 1usize); + self.count_nominal(61usize, 8usize, &event.state); let _ = context; let _ = meta; let _ = event; @@ -1868,8 +2132,10 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::ConnectionMigrationDenied, ) { - self.count(57usize, 32usize, 1usize); - self.count_nominal(58usize, 9usize, &event.reason); + #[allow(unused_imports)] + use api::*; + self.count(62usize, 32usize, 1usize); + self.count_nominal(63usize, 9usize, &event.reason); let _ = context; let _ = meta; let _ = event; @@ -1881,8 +2147,46 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::HandshakeStatusUpdated, ) { - self.count(59usize, 33usize, 1usize); - self.count_nominal(60usize, 10usize, &event.status); + #[allow(unused_imports)] + use api::*; + self.count(64usize, 33usize, 1usize); + { + fn check(evt: &api::HandshakeStatusUpdated) -> bool { + matches!(evt.status, HandshakeStatus::Complete { .. }) + } + if check(event) { + self.time( + 65usize, + 5usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); + } + } + { + fn check(evt: &api::HandshakeStatusUpdated) -> bool { + matches!(evt.status, HandshakeStatus::Confirmed { .. }) + } + if check(event) { + self.time( + 66usize, + 6usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); + } + } + { + fn check(evt: &api::HandshakeStatusUpdated) -> bool { + matches!(evt.status, HandshakeStatus::HandshakeDoneAcked { .. }) + } + if check(event) { + self.time( + 67usize, + 7usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); + } + } + self.count_nominal(68usize, 10usize, &event.status); let _ = context; let _ = meta; let _ = event; @@ -1894,7 +2198,9 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::TlsExporterReady, ) { - self.count(61usize, 34usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(69usize, 34usize, 1usize); let _ = context; let _ = meta; let _ = event; @@ -1906,7 +2212,9 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::PathChallengeUpdated, ) { - self.count(62usize, 35usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(70usize, 35usize, 1usize); let _ = context; let _ = meta; let _ = event; @@ -1918,7 +2226,14 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::TlsClientHello, ) { - self.count(63usize, 36usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(71usize, 36usize, 1usize); + self.time( + 72usize, + 8usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); let _ = context; let _ = meta; let _ = event; @@ -1930,7 +2245,14 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::TlsServerHello, ) { - self.count(64usize, 37usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(73usize, 37usize, 1usize); + self.time( + 74usize, + 9usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); let _ = context; let _ = meta; let _ = event; @@ -1942,9 +2264,11 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::RxStreamProgress, ) { - self.count(65usize, 38usize, 1usize); - self.count(66usize, 39usize, event.bytes); - self.measure(67usize, 14usize, event.bytes); + #[allow(unused_imports)] + use api::*; + self.count(75usize, 38usize, 1usize); + self.count(76usize, 39usize, event.bytes); + self.measure(77usize, 14usize, event.bytes); let _ = context; let _ = meta; let _ = event; @@ -1956,9 +2280,11 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::TxStreamProgress, ) { - self.count(68usize, 40usize, 1usize); - self.count(69usize, 41usize, event.bytes); - self.measure(70usize, 15usize, event.bytes); + #[allow(unused_imports)] + use api::*; + self.count(78usize, 40usize, 1usize); + self.count(79usize, 41usize, event.bytes); + self.measure(80usize, 15usize, event.bytes); let _ = context; let _ = meta; let _ = event; @@ -1970,7 +2296,9 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::KeepAliveTimerExpired, ) { - self.count(71usize, 42usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(81usize, 42usize, 1usize); let _ = context; let _ = meta; let _ = event; @@ -1982,10 +2310,12 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::MtuUpdated, ) { - self.count(72usize, 43usize, 1usize); - self.measure(73usize, 16usize, event.mtu); - self.count_nominal(74usize, 11usize, &event.cause); - self.count_bool(75usize, 2usize, event.search_complete); + #[allow(unused_imports)] + use api::*; + self.count(82usize, 43usize, 1usize); + self.measure(83usize, 16usize, event.mtu); + self.count_nominal(84usize, 11usize, &event.cause); + self.count_bool(85usize, 2usize, event.search_complete); let _ = context; let _ = meta; let _ = event; @@ -1997,9 +2327,17 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::SlowStartExited, ) { - self.count(76usize, 44usize, 1usize); - self.count_nominal(77usize, 12usize, &event.cause); - self.measure(78usize, 17usize, event.congestion_window); + #[allow(unused_imports)] + use api::*; + self.count(86usize, 44usize, 1usize); + self.count_nominal(87usize, 12usize, &event.cause); + self.time_nominal( + 88usize, + 0usize, + &event.cause, + meta.timestamp.saturating_duration_since(context.start_time), + ); + self.measure(89usize, 17usize, event.congestion_window); let _ = context; let _ = meta; let _ = event; @@ -2011,7 +2349,9 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::DeliveryRateSampled, ) { - self.count(79usize, 45usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(90usize, 45usize, 1usize); let _ = context; let _ = meta; let _ = event; @@ -2023,10 +2363,12 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::PacingRateUpdated, ) { - self.count(80usize, 46usize, 1usize); - self.measure(81usize, 18usize, event.bytes_per_second); - self.measure(82usize, 19usize, event.burst_size); - self.measure(83usize, 20usize, event.pacing_gain); + #[allow(unused_imports)] + use api::*; + self.count(91usize, 46usize, 1usize); + self.measure(92usize, 18usize, event.bytes_per_second); + self.measure(93usize, 19usize, event.burst_size); + self.measure(94usize, 20usize, event.pacing_gain); let _ = context; let _ = meta; let _ = event; @@ -2038,8 +2380,10 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::BbrStateChanged, ) { - self.count(84usize, 47usize, 1usize); - self.count_nominal(85usize, 13usize, &event.state); + #[allow(unused_imports)] + use api::*; + self.count(95usize, 47usize, 1usize); + self.count_nominal(96usize, 13usize, &event.state); let _ = context; let _ = meta; let _ = event; @@ -2051,8 +2395,58 @@ impl event::Subscriber for Subscriber { meta: &api::ConnectionMeta, event: &api::DcStateChanged, ) { - self.count(86usize, 48usize, 1usize); - self.count_nominal(87usize, 14usize, &event.state); + #[allow(unused_imports)] + use api::*; + self.count(97usize, 48usize, 1usize); + { + fn check(evt: &api::DcStateChanged) -> bool { + matches!(evt.state, DcState::VersionNegotiated { .. }) + } + if check(event) { + self.time( + 98usize, + 10usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); + } + } + { + fn check(evt: &api::DcStateChanged) -> bool { + matches!(evt.state, DcState::VersionNegotiated { .. }) + } + if check(event) { + self.time( + 99usize, + 11usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); + } + } + { + fn check(evt: &api::DcStateChanged) -> bool { + matches!(evt.state, DcState::PathSecretsReady { .. }) + } + if check(event) { + self.time( + 100usize, + 12usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); + } + } + { + fn check(evt: &api::DcStateChanged) -> bool { + matches!(evt.state, DcState::Complete { .. }) + } + if check(event) { + self.time( + 101usize, + 13usize, + meta.timestamp.saturating_duration_since(context.start_time), + ); + } + } + self.count_nominal(102usize, 14usize, &event.state); let _ = context; let _ = meta; let _ = event; @@ -2063,7 +2457,9 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::VersionInformation, ) { - self.count(88usize, 49usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(103usize, 49usize, 1usize); let _ = event; let _ = meta; } @@ -2073,7 +2469,9 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::EndpointPacketSent, ) { - self.count(89usize, 50usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(104usize, 50usize, 1usize); let _ = event; let _ = meta; } @@ -2083,7 +2481,9 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::EndpointPacketReceived, ) { - self.count(90usize, 51usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(105usize, 51usize, 1usize); let _ = event; let _ = meta; } @@ -2093,10 +2493,12 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::EndpointDatagramSent, ) { - self.count(91usize, 52usize, 1usize); - self.measure(92usize, 21usize, event.len); - self.measure(93usize, 22usize, event.len); - self.measure(94usize, 23usize, event.gso_offset); + #[allow(unused_imports)] + use api::*; + self.count(106usize, 52usize, 1usize); + self.measure(107usize, 21usize, event.len); + self.measure(108usize, 22usize, event.len); + self.measure(109usize, 23usize, event.gso_offset); let _ = event; let _ = meta; } @@ -2106,9 +2508,11 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::EndpointDatagramReceived, ) { - self.count(95usize, 53usize, 1usize); - self.measure(96usize, 24usize, event.len); - self.measure(97usize, 25usize, event.len); + #[allow(unused_imports)] + use api::*; + self.count(110usize, 53usize, 1usize); + self.measure(111usize, 24usize, event.len); + self.measure(112usize, 25usize, event.len); let _ = event; let _ = meta; } @@ -2118,10 +2522,12 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::EndpointDatagramDropped, ) { - self.count(98usize, 54usize, 1usize); - self.measure(99usize, 26usize, event.len); - self.measure(100usize, 27usize, event.len); - self.count_nominal(101usize, 15usize, &event.reason); + #[allow(unused_imports)] + use api::*; + self.count(113usize, 54usize, 1usize); + self.measure(114usize, 26usize, event.len); + self.measure(115usize, 27usize, event.len); + self.count_nominal(116usize, 15usize, &event.reason); let _ = event; let _ = meta; } @@ -2131,52 +2537,62 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::EndpointConnectionAttemptFailed, ) { - self.count(102usize, 55usize, 1usize); - self.count_nominal(103usize, 16usize, &event.error); + #[allow(unused_imports)] + use api::*; + self.count(117usize, 55usize, 1usize); + self.count_nominal(118usize, 16usize, &event.error); let _ = event; let _ = meta; } #[inline] fn on_platform_tx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformTx) { - self.count(104usize, 56usize, 1usize); - self.count(105usize, 57usize, event.count); - self.measure(106usize, 28usize, event.count); - self.count(107usize, 58usize, event.syscalls); - self.measure(108usize, 29usize, event.syscalls); - self.count(109usize, 59usize, event.blocked_syscalls); - self.measure(110usize, 30usize, event.blocked_syscalls); - self.count(111usize, 60usize, event.total_errors); - self.measure(112usize, 31usize, event.total_errors); - self.count(113usize, 61usize, event.dropped_errors); - self.measure(114usize, 32usize, event.dropped_errors); + #[allow(unused_imports)] + use api::*; + self.count(119usize, 56usize, 1usize); + self.count(120usize, 57usize, event.count); + self.measure(121usize, 28usize, event.count); + self.count(122usize, 58usize, event.syscalls); + self.measure(123usize, 29usize, event.syscalls); + self.count(124usize, 59usize, event.blocked_syscalls); + self.measure(125usize, 30usize, event.blocked_syscalls); + self.count(126usize, 60usize, event.total_errors); + self.measure(127usize, 31usize, event.total_errors); + self.count(128usize, 61usize, event.dropped_errors); + self.measure(129usize, 32usize, event.dropped_errors); let _ = event; let _ = meta; } #[inline] fn on_platform_tx_error(&mut self, meta: &api::EndpointMeta, event: &api::PlatformTxError) { - self.count(115usize, 62usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(130usize, 62usize, 1usize); let _ = event; let _ = meta; } #[inline] fn on_platform_rx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformRx) { - self.count(116usize, 63usize, 1usize); - self.count(117usize, 64usize, event.count); - self.measure(118usize, 33usize, event.count); - self.count(119usize, 65usize, event.syscalls); - self.measure(120usize, 34usize, event.syscalls); - self.count(121usize, 66usize, event.blocked_syscalls); - self.measure(122usize, 35usize, event.blocked_syscalls); - self.count(123usize, 67usize, event.total_errors); - self.measure(124usize, 36usize, event.total_errors); - self.count(125usize, 68usize, event.dropped_errors); - self.measure(126usize, 37usize, event.dropped_errors); + #[allow(unused_imports)] + use api::*; + self.count(131usize, 63usize, 1usize); + self.count(132usize, 64usize, event.count); + self.measure(133usize, 33usize, event.count); + self.count(134usize, 65usize, event.syscalls); + self.measure(135usize, 34usize, event.syscalls); + self.count(136usize, 66usize, event.blocked_syscalls); + self.measure(137usize, 35usize, event.blocked_syscalls); + self.count(138usize, 67usize, event.total_errors); + self.measure(139usize, 36usize, event.total_errors); + self.count(140usize, 68usize, event.dropped_errors); + self.measure(141usize, 37usize, event.dropped_errors); let _ = event; let _ = meta; } #[inline] fn on_platform_rx_error(&mut self, meta: &api::EndpointMeta, event: &api::PlatformRxError) { - self.count(127usize, 69usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(142usize, 69usize, 1usize); let _ = event; let _ = meta; } @@ -2186,7 +2602,9 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::PlatformFeatureConfigured, ) { - self.count(128usize, 70usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(143usize, 70usize, 1usize); let _ = event; let _ = meta; } @@ -2196,7 +2614,9 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::PlatformEventLoopWakeup, ) { - self.count(129usize, 71usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(144usize, 71usize, 1usize); let _ = event; let _ = meta; } @@ -2206,8 +2626,10 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::PlatformEventLoopSleep, ) { - self.count(130usize, 72usize, 1usize); - self.time(131usize, 0usize, event.processing_duration); + #[allow(unused_imports)] + use api::*; + self.count(145usize, 72usize, 1usize); + self.time(146usize, 14usize, event.processing_duration); let _ = event; let _ = meta; } @@ -2217,7 +2639,9 @@ impl event::Subscriber for Subscriber { meta: &api::EndpointMeta, event: &api::PlatformEventLoopStarted, ) { - self.count(132usize, 73usize, 1usize); + #[allow(unused_imports)] + use api::*; + self.count(147usize, 73usize, 1usize); let _ = event; let _ = meta; } diff --git a/quic/s2n-quic-core/src/event/generated/metrics/probe.rs b/quic/s2n-quic-core/src/event/generated/metrics/probe.rs index e079a503be..47387bca12 100644 --- a/quic/s2n-quic-core/src/event/generated/metrics/probe.rs +++ b/quic/s2n-quic-core/src/event/generated/metrics/probe.rs @@ -39,60 +39,60 @@ mod counter { 32usize => Self(packet_dropped), 34usize => Self(key_update), 35usize => Self(key_space_discarded), - 37usize => Self(connection_started), - 38usize => Self(connection_closed), - 40usize => Self(duplicate_packet), - 42usize => Self(transport_parameters_received), - 43usize => Self(datagram_sent), - 44usize => Self(datagram_sent__bytes__total), - 47usize => Self(datagram_received), - 48usize => Self(datagram_received__bytes__total), - 50usize => Self(datagram_dropped), - 51usize => Self(datagram_dropped__bytes__total), - 54usize => Self(connection_id_updated), - 55usize => Self(ecn_state_changed), - 57usize => Self(connection_migration_denied), - 59usize => Self(handshake_status_updated), - 61usize => Self(tls_exporter_ready), - 62usize => Self(path_challenge_updated), - 63usize => Self(tls_client_hello), - 64usize => Self(tls_server_hello), - 65usize => Self(rx_stream_progress), - 66usize => Self(rx_stream_progress__bytes__total), - 68usize => Self(tx_stream_progress), - 69usize => Self(tx_stream_progress__bytes__total), - 71usize => Self(keep_alive_timer_expired), - 72usize => Self(mtu_updated), - 76usize => Self(slow_start_exited), - 79usize => Self(delivery_rate_sampled), - 80usize => Self(pacing_rate_updated), - 84usize => Self(bbr_state_changed), - 86usize => Self(dc_state_changed), - 88usize => Self(version_information), - 89usize => Self(endpoint_packet_sent), - 90usize => Self(endpoint_packet_received), - 91usize => Self(endpoint_datagram_sent), - 95usize => Self(endpoint_datagram_received), - 98usize => Self(endpoint_datagram_dropped), - 102usize => Self(endpoint_connection_attempt_failed), - 104usize => Self(platform_tx), - 105usize => Self(platform_tx__packets__total), - 107usize => Self(platform_tx__syscalls__total), - 109usize => Self(platform_tx__syscalls__blocked__total), - 111usize => Self(platform_tx__errors__total), - 113usize => Self(platform_tx__errors__dropped__total), - 115usize => Self(platform_tx_error), - 116usize => Self(platform_rx), - 117usize => Self(platform_rx__packets__total), - 119usize => Self(platform_rx__syscalls__total), - 121usize => Self(platform_rx__syscalls__blocked__total), - 123usize => Self(platform_rx__errors__total), - 125usize => Self(platform_rx__errors__dropped__total), - 127usize => Self(platform_rx_error), - 128usize => Self(platform_feature_configured), - 129usize => Self(platform_event_loop_wakeup), - 130usize => Self(platform_event_loop_sleep), - 132usize => Self(platform_event_loop_started), + 40usize => Self(connection_started), + 41usize => Self(connection_closed), + 44usize => Self(duplicate_packet), + 46usize => Self(transport_parameters_received), + 48usize => Self(datagram_sent), + 49usize => Self(datagram_sent__bytes__total), + 52usize => Self(datagram_received), + 53usize => Self(datagram_received__bytes__total), + 55usize => Self(datagram_dropped), + 56usize => Self(datagram_dropped__bytes__total), + 59usize => Self(connection_id_updated), + 60usize => Self(ecn_state_changed), + 62usize => Self(connection_migration_denied), + 64usize => Self(handshake_status_updated), + 69usize => Self(tls_exporter_ready), + 70usize => Self(path_challenge_updated), + 71usize => Self(tls_client_hello), + 73usize => Self(tls_server_hello), + 75usize => Self(rx_stream_progress), + 76usize => Self(rx_stream_progress__bytes__total), + 78usize => Self(tx_stream_progress), + 79usize => Self(tx_stream_progress__bytes__total), + 81usize => Self(keep_alive_timer_expired), + 82usize => Self(mtu_updated), + 86usize => Self(slow_start_exited), + 90usize => Self(delivery_rate_sampled), + 91usize => Self(pacing_rate_updated), + 95usize => Self(bbr_state_changed), + 97usize => Self(dc_state_changed), + 103usize => Self(version_information), + 104usize => Self(endpoint_packet_sent), + 105usize => Self(endpoint_packet_received), + 106usize => Self(endpoint_datagram_sent), + 110usize => Self(endpoint_datagram_received), + 113usize => Self(endpoint_datagram_dropped), + 117usize => Self(endpoint_connection_attempt_failed), + 119usize => Self(platform_tx), + 120usize => Self(platform_tx__packets__total), + 122usize => Self(platform_tx__syscalls__total), + 124usize => Self(platform_tx__syscalls__blocked__total), + 126usize => Self(platform_tx__errors__total), + 128usize => Self(platform_tx__errors__dropped__total), + 130usize => Self(platform_tx_error), + 131usize => Self(platform_rx), + 132usize => Self(platform_rx__packets__total), + 134usize => Self(platform_rx__syscalls__total), + 136usize => Self(platform_rx__syscalls__blocked__total), + 138usize => Self(platform_rx__errors__total), + 140usize => Self(platform_rx__errors__dropped__total), + 142usize => Self(platform_rx_error), + 143usize => Self(platform_feature_configured), + 144usize => Self(platform_event_loop_wakeup), + 145usize => Self(platform_event_loop_sleep), + 147usize => Self(platform_event_loop_started), _ => unreachable!("invalid info: {info:?}"), } } @@ -263,7 +263,7 @@ mod counter { match info.id { 16usize => Self(packet_lost__is_mtu_probe), 26usize => Self(recovery_metrics__congestion_limited), - 75usize => Self(mtu_updated__search_complete), + 85usize => Self(mtu_updated__search_complete), _ => unreachable!("invalid info: {info:?}"), } } @@ -296,19 +296,19 @@ mod counter { 12usize => Self(frame_received__frame), 28usize => Self(congestion__source), 33usize => Self(packet_dropped__reason), - 36usize => Self(key_space_discarded__space), - 39usize => Self(connection_closed__error), - 41usize => Self(duplicate_packet__error), - 53usize => Self(datagram_dropped__reason), - 56usize => Self(ecn_state_changed__state), - 58usize => Self(connection_migration_denied__reason), - 60usize => Self(handshake_status_updated__status), - 74usize => Self(mtu_updated__cause), - 77usize => Self(slow_start_exited__cause), - 85usize => Self(bbr_state_changed__state), - 87usize => Self(dc_state_changed__state), - 101usize => Self(endpoint_datagram_dropped__reason), - 103usize => Self(endpoint_connection_attempt_failed__error), + 39usize => Self(key_space_discarded__space), + 43usize => Self(connection_closed__error), + 45usize => Self(duplicate_packet__error), + 58usize => Self(datagram_dropped__reason), + 61usize => Self(ecn_state_changed__state), + 63usize => Self(connection_migration_denied__reason), + 68usize => Self(handshake_status_updated__status), + 84usize => Self(mtu_updated__cause), + 87usize => Self(slow_start_exited__cause), + 96usize => Self(bbr_state_changed__state), + 102usize => Self(dc_state_changed__state), + 116usize => Self(endpoint_datagram_dropped__reason), + 118usize => Self(endpoint_connection_attempt_failed__error), _ => unreachable!("invalid info: {info:?}"), } } @@ -397,34 +397,34 @@ mod measure { 23usize => Self(recovery_metrics__pto_count), 24usize => Self(recovery_metrics__congestion_window), 25usize => Self(recovery_metrics__bytes_in_flight), - 45usize => Self(datagram_sent__bytes), - 46usize => Self(datagram_sent__gso_offset), - 49usize => Self(datagram_received__bytes), - 52usize => Self(datagram_dropped__bytes), - 67usize => Self(rx_stream_progress__bytes), - 70usize => Self(tx_stream_progress__bytes), - 73usize => Self(mtu_updated__mtu), - 78usize => Self(slow_start_exited__congestion_window), - 81usize => Self(pacing_rate_updated__bytes_per_second), - 82usize => Self(pacing_rate_updated__burst_size), - 83usize => Self(pacing_rate_updated__pacing_gain), - 92usize => Self(endpoint_datagram_sent__bytes), - 93usize => Self(endpoint_datagram_sent__bytes__total), - 94usize => Self(endpoint_datagram_sent__gso_offset), - 96usize => Self(endpoint_datagram_received__bytes), - 97usize => Self(endpoint_datagram_received__bytes__total), - 99usize => Self(endpoint_datagram_dropped__bytes), - 100usize => Self(endpoint_datagram_dropped__bytes__total), - 106usize => Self(platform_tx__packets), - 108usize => Self(platform_tx__syscalls), - 110usize => Self(platform_tx__syscalls__blocked), - 112usize => Self(platform_tx__errors), - 114usize => Self(platform_tx__errors__dropped), - 118usize => Self(platform_rx__packets), - 120usize => Self(platform_rx__syscalls), - 122usize => Self(platform_rx__syscalls__blocked), - 124usize => Self(platform_rx__errors), - 126usize => Self(platform_rx__errors__dropped), + 50usize => Self(datagram_sent__bytes), + 51usize => Self(datagram_sent__gso_offset), + 54usize => Self(datagram_received__bytes), + 57usize => Self(datagram_dropped__bytes), + 77usize => Self(rx_stream_progress__bytes), + 80usize => Self(tx_stream_progress__bytes), + 83usize => Self(mtu_updated__mtu), + 89usize => Self(slow_start_exited__congestion_window), + 92usize => Self(pacing_rate_updated__bytes_per_second), + 93usize => Self(pacing_rate_updated__burst_size), + 94usize => Self(pacing_rate_updated__pacing_gain), + 107usize => Self(endpoint_datagram_sent__bytes), + 108usize => Self(endpoint_datagram_sent__bytes__total), + 109usize => Self(endpoint_datagram_sent__gso_offset), + 111usize => Self(endpoint_datagram_received__bytes), + 112usize => Self(endpoint_datagram_received__bytes__total), + 114usize => Self(endpoint_datagram_dropped__bytes), + 115usize => Self(endpoint_datagram_dropped__bytes__total), + 121usize => Self(platform_tx__packets), + 123usize => Self(platform_tx__syscalls), + 125usize => Self(platform_tx__syscalls__blocked), + 127usize => Self(platform_tx__errors), + 129usize => Self(platform_tx__errors__dropped), + 133usize => Self(platform_rx__packets), + 135usize => Self(platform_rx__syscalls), + 137usize => Self(platform_rx__syscalls__blocked), + 139usize => Self(platform_rx__errors), + 141usize => Self(platform_rx__errors__dropped), _ => unreachable!("invalid info: {info:?}"), } } @@ -539,7 +539,21 @@ mod timer { impl Recorder { pub(crate) fn new(info: &'static Info) -> Self { match info.id { - 131usize => Self(platform_event_loop_sleep__processing_duration), + 36usize => Self(key_space_discarded__initial__latency), + 37usize => Self(key_space_discarded__handshake__latency), + 38usize => Self(key_space_discarded__one_rtt__latency), + 42usize => Self(connection_closed__latency), + 47usize => Self(transport_parameters_received__latency), + 65usize => Self(handshake_status_updated__complete__latency), + 66usize => Self(handshake_status_updated__confirmed__latency), + 67usize => Self(handshake_status_updated__handshake_done_acked__latency), + 72usize => Self(tls_client_hello__latency), + 74usize => Self(tls_server_hello__latency), + 98usize => Self(dc_state_changed__version_negotiated__latency), + 99usize => Self(dc_state_changed__no_version_negotiated__latency), + 100usize => Self(dc_state_changed__path_secrets__latency), + 101usize => Self(dc_state_changed__complete__latency), + 146usize => Self(platform_event_loop_sleep__processing_duration), _ => unreachable!("invalid info: {info:?}"), } } @@ -551,10 +565,72 @@ mod timer { } define!( extern "probe" { + # [link_name = s2n_quic__event__timer__key_space_discarded__initial__latency] + fn key_space_discarded__initial__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__key_space_discarded__handshake__latency] + fn key_space_discarded__handshake__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__key_space_discarded__one_rtt__latency] + fn key_space_discarded__one_rtt__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__connection_closed__latency] + fn connection_closed__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__transport_parameters_received__latency] + fn transport_parameters_received__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__handshake_status_updated__complete__latency] + fn handshake_status_updated__complete__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__handshake_status_updated__confirmed__latency] + fn handshake_status_updated__confirmed__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__handshake_status_updated__handshake_done_acked__latency] + fn handshake_status_updated__handshake_done_acked__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__tls_client_hello__latency] + fn tls_client_hello__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__tls_server_hello__latency] + fn tls_server_hello__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__dc_state_changed__version_negotiated__latency] + fn dc_state_changed__version_negotiated__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__dc_state_changed__no_version_negotiated__latency] + fn dc_state_changed__no_version_negotiated__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__dc_state_changed__path_secrets__latency] + fn dc_state_changed__path_secrets__latency(value: core::time::Duration); + # [link_name = s2n_quic__event__timer__dc_state_changed__complete__latency] + fn dc_state_changed__complete__latency(value: core::time::Duration); # [link_name = s2n_quic__event__timer__platform_event_loop_sleep__processing_duration] fn platform_event_loop_sleep__processing_duration(value: core::time::Duration); } ); + pub mod nominal { + #![allow(non_snake_case)] + use super::*; + use crate::event::metrics::aggregate::Metric; + pub struct Recorder(fn(core::time::Duration, u64, &info::Str)); + impl Recorder { + pub(crate) fn new(info: &'static Info, _variant: &'static info::Variant) -> Self { + match info.id { + 88usize => Self(slow_start_exited__latency), + _ => unreachable!("invalid info: {info:?}"), + } + } + } + impl NominalRecorder for Recorder { + fn record( + &self, + _info: &'static Info, + variant: &'static info::Variant, + value: T, + ) { + (self.0)(value.as_duration(), variant.id as _, variant.name); + } + } + define!( + extern "probe" { + # [link_name = s2n_quic__event__timer__nominal__slow_start_exited__latency] + fn slow_start_exited__latency( + value: core::time::Duration, + variant: u64, + variant_name: &info::Str, + ); + } + ); + } } #[derive(Default)] pub struct Registry(()); @@ -565,6 +641,7 @@ impl aggregate::Registry for Registry { type Measure = measure::Recorder; type Gauge = gauge::Recorder; type Timer = timer::Recorder; + type NominalTimer = timer::nominal::Recorder; #[inline] fn register_counter(&self, info: &'static Info) -> Self::Counter { counter::Recorder::new(info) @@ -593,4 +670,12 @@ impl aggregate::Registry for Registry { fn register_timer(&self, info: &'static Info) -> Self::Timer { timer::Recorder::new(info) } + #[inline] + fn register_nominal_timer( + &self, + info: &'static Info, + variant: &'static info::Variant, + ) -> Self::NominalTimer { + timer::nominal::Recorder::new(info, variant) + } } diff --git a/quic/s2n-quic-core/src/event/metrics/aggregate.rs b/quic/s2n-quic-core/src/event/metrics/aggregate.rs index 908f1c584c..0bb97fec45 100644 --- a/quic/s2n-quic-core/src/event/metrics/aggregate.rs +++ b/quic/s2n-quic-core/src/event/metrics/aggregate.rs @@ -22,6 +22,7 @@ pub trait Registry: 'static + Send + Sync { type Measure: Recorder; type Gauge: Recorder; type Timer: Recorder; + type NominalTimer: NominalRecorder; fn register_counter(&self, info: &'static Info) -> Self::Counter; @@ -38,6 +39,12 @@ pub trait Registry: 'static + Send + Sync { fn register_gauge(&self, info: &'static Info) -> Self::Gauge; fn register_timer(&self, info: &'static Info) -> Self::Timer; + + fn register_nominal_timer( + &self, + info: &'static Info, + variant: &'static info::Variant, + ) -> Self::NominalTimer; } impl Registry for (A, B) @@ -51,6 +58,7 @@ where type Measure = (A::Measure, B::Measure); type Gauge = (A::Gauge, B::Gauge); type Timer = (A::Timer, B::Timer); + type NominalTimer = (A::NominalTimer, B::NominalTimer); #[inline] fn register_counter(&self, info: &'static Info) -> Self::Counter { @@ -91,6 +99,18 @@ where fn register_timer(&self, info: &'static Info) -> Self::Timer { (self.0.register_timer(info), self.1.register_timer(info)) } + + #[inline] + fn register_nominal_timer( + &self, + info: &'static Info, + variant: &'static info::Variant, + ) -> Self::NominalTimer { + ( + self.0.register_nominal_timer(info, variant), + self.1.register_nominal_timer(info, variant), + ) + } } #[cfg(feature = "alloc")] @@ -101,6 +121,7 @@ impl Registry for alloc::sync::Arc { type Measure = T::Measure; type Gauge = T::Gauge; type Timer = T::Timer; + type NominalTimer = T::NominalTimer; #[inline] fn register_counter(&self, info: &'static Info) -> Self::Counter { @@ -135,4 +156,13 @@ impl Registry for alloc::sync::Arc { fn register_timer(&self, info: &'static Info) -> Self::Timer { self.as_ref().register_timer(info) } + + #[inline] + fn register_nominal_timer( + &self, + info: &'static Info, + variant: &'static info::Variant, + ) -> Self::NominalTimer { + self.as_ref().register_nominal_timer(info, variant) + } } diff --git a/quic/s2n-quic-core/src/event/metrics/aggregate/probe/dynamic.rs b/quic/s2n-quic-core/src/event/metrics/aggregate/probe/dynamic.rs index cde0eecfc3..f28b6ec23c 100644 --- a/quic/s2n-quic-core/src/event/metrics/aggregate/probe/dynamic.rs +++ b/quic/s2n-quic-core/src/event/metrics/aggregate/probe/dynamic.rs @@ -17,6 +17,7 @@ impl aggregate::Registry for Registry { type Measure = Measure; type Gauge = Gauge; type Timer = Timer; + type NominalTimer = NominalTimer; #[inline] fn register_counter(&self, info: &'static Info) -> Self::Counter { @@ -51,6 +52,15 @@ impl aggregate::Registry for Registry { fn register_timer(&self, info: &'static Info) -> Self::Timer { Self::Timer::new(info) } + + #[inline] + fn register_nominal_timer( + &self, + info: &'static Info, + variant: &'static info::Variant, + ) -> Self::NominalTimer { + Self::NominalTimer::new(info, variant) + } } macro_rules! recorder { @@ -141,6 +151,15 @@ recorder!( s2n_quic__timer__record, as_duration: core::time::Duration ); +recorder!( + NominalRecorder, + NominalTimer, + nominal_timer, + s2n_quic__timer__nominal__register, + s2n_quic__timer__nominal__record, + as_duration: core::time::Duration, + variant: &'static info::Variant +); mod bool_counter { use super::*; diff --git a/quic/s2n-quic-core/src/time/clock.rs b/quic/s2n-quic-core/src/time/clock.rs index c4f764d3e2..71f75f3703 100644 --- a/quic/s2n-quic-core/src/time/clock.rs +++ b/quic/s2n-quic-core/src/time/clock.rs @@ -40,7 +40,7 @@ pub trait Timer { impl_ready_future!(Timer, TimerReady, ()); /// A clock which always returns a Timestamp of value 1us -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Default)] pub struct NoopClock; impl Clock for NoopClock { diff --git a/quic/s2n-quic-events/src/output/metrics/aggregate.rs b/quic/s2n-quic-events/src/output/metrics/aggregate.rs index dd4809c7ee..e31253f2f0 100644 --- a/quic/s2n-quic-events/src/output/metrics/aggregate.rs +++ b/quic/s2n-quic-events/src/output/metrics/aggregate.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::{ - parser::{File, Subject}, + parser::{File, Metric, MetricNoUnit, Subject}, Output, }; use proc_macro2::{Ident, Span, TokenStream}; @@ -52,8 +52,8 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { quote!(u64), quote!(.as_u64()), ); - nominal_counters.registry_type = RegistryType::NominalCounter { - nominal_offsets: quote!(nominal_offsets), + nominal_counters.registry_type = RegistryType::Nominal { + offsets: quote!(nominal_counter_offsets), }; let mut measures = Registry::new( @@ -78,6 +78,17 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { quote!(.as_duration()), ); + let mut nominal_timers = Registry::new( + quote!(nominal_timers), + quote!(register_nominal_timer), + format!("{}__event__timer__nominal", output.crate_name), + quote!(core::time::Duration), + quote!(.as_duration()), + ); + nominal_timers.registry_type = RegistryType::Nominal { + offsets: quote!(nominal_timer_offsets), + }; + let units_none = Ident::new("None", Span::call_site()); let units_duration = Ident::new("Duration", Span::call_site()); @@ -96,63 +107,98 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { self.count(#count_info, #count_id, 1usize); )); + for checkpoint in event.attrs.checkpoint.iter() { + let evt = &event.ident; + let name = format!("{snake}.{}", checkpoint.name.value()); + let info = &info.push(&name, &units_duration); + let id = timers.push(info, None); + let duration = quote!(meta.timestamp.saturating_duration_since(context.start_time)); + + if let Some(condition) = checkpoint.condition.as_ref() { + let inputs = &condition.inputs; + assert_eq!(inputs.len(), 1); + let input = &inputs[0]; + let body = &condition.body; + on_event.extend(quote!({ + fn check(#input: &api::#evt) -> bool { + #body + } + if check(event) { + self.time(#info, #id, #duration); + } + })); + } else { + on_event.extend(quote!( + self.time(#info, #id, #duration); + )); + } + } + for field in &event.fields { + let field_name = field.ident.as_ref().unwrap(); + let metrics = [ - (quote!(count), &field.attrs.counter, &mut counters, None), + ( + quote!(count), + metrics_iter(&field.attrs.counter), + &mut counters, + quote!(event.#field_name), + None, + ), ( quote!(count_nominal), - &field.attrs.nominal_counter, + metrics_iter(&field.attrs.nominal_counter), &mut nominal_counters, + quote!(&event.#field_name), Some(&field.ty), ), - (quote!(measure), &field.attrs.measure, &mut measures, None), - (quote!(gauge), &field.attrs.gauge, &mut gauges, None), - ]; - - for (function, list, target, field_ty) in metrics { - let borrow = if field_ty.is_some() { - quote!(&) - } else { - quote!() - }; - for metric in list { - let name = format!("{snake}.{}", metric.name.value()); - let units = metric.unit.as_ref().unwrap_or(&units_none); - let info = &info.push(&name, units); - let id = target.push(info, field_ty); - - let field = field.ident.as_ref().unwrap(); - on_event.extend(quote!( - self.#function(#info, #id, #borrow event.#field); - )); - } - } - - let metrics = [ + ( + quote!(measure), + metrics_iter(&field.attrs.measure), + &mut measures, + quote!(event.#field_name), + None, + ), + ( + quote!(gauge), + metrics_iter(&field.attrs.gauge), + &mut gauges, + quote!(event.#field_name), + None, + ), ( quote!(time), - &field.attrs.timer, + metrics_iter_with_unit(&field.attrs.timer, Some(&units_duration)), &mut timers, - &units_duration, + quote!(event.#field_name), + None, ), ( quote!(count_bool), - &field.attrs.bool_counter, + metrics_iter_with_unit(&field.attrs.bool_counter, Some(&units_none)), &mut bool_counters, - &units_none, + quote!(event.#field_name), + None, + ), + ( + quote!(time_nominal), + metrics_iter_with_unit(&field.attrs.nominal_checkpoint, Some(&units_duration)), + &mut nominal_timers, + quote!(&event.#field_name, meta.timestamp.saturating_duration_since(context.start_time)), + Some(&field.ty), ), ]; - for (function, list, target, units) in metrics { - for metric in list { - let name = format!("{snake}.{}", metric.name.value()); + for (function, list, target, value, field_ty) in metrics { + for (name, units) in list { + let name = format!("{snake}.{}", name.value()); + let units = units.unwrap_or(&units_none); let info = &info.push(&name, units); - let id = target.push(info, None); + let id = target.push(info, field_ty); - let field = field.ident.as_ref().unwrap(); on_event.extend(quote!( - self.#function(#info, #id, event.#field); - )) + self.#function(#info, #id, #value); + )); } } } @@ -167,6 +213,9 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { meta: &api::ConnectionMeta, event: &api::#ident ) { + #[allow(unused_imports)] + use api::*; + #on_event let _ = context; let _ = meta; @@ -182,6 +231,9 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { meta: &api::EndpointMeta, event: &api::#ident ) { + #[allow(unused_imports)] + use api::*; + #on_event let _ = event; let _ = meta; @@ -209,6 +261,9 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { let timers_init = timers.init(); let timers_probes = timers.probe(); let timers_len = timers.len; + let nominal_timers_init = nominal_timers.init(); + let nominal_timers_probes = nominal_timers.probe(); + let nominal_timers_len = nominal_timers.len; let info_len = info.len; let mut imports = quote!(); @@ -238,6 +293,12 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { static INFO: &[Info; #info_len] = &[#info]; + #[derive(Clone, Copy, Debug)] + #[allow(dead_code)] + pub struct ConnectionContext { + start_time: crate::event::Timestamp, + } + pub struct Subscriber { #[allow(dead_code)] counters: Box<[R::Counter; #counters_len]>, @@ -246,7 +307,7 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { #[allow(dead_code)] nominal_counters: Box<[R::NominalCounter]>, #[allow(dead_code)] - nominal_offsets: Box<[usize; #nominal_counters_len]>, + nominal_counter_offsets: Box<[usize; #nominal_counters_len]>, #[allow(dead_code)] measures: Box<[R::Measure; #measures_len]>, #[allow(dead_code)] @@ -254,6 +315,10 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { #[allow(dead_code)] timers: Box<[R::Timer; #timers_len]>, #[allow(dead_code)] + nominal_timers: Box<[R::NominalTimer]>, + #[allow(dead_code)] + nominal_timer_offsets: Box<[usize; #nominal_timers_len]>, + #[allow(dead_code)] registry: R, } @@ -275,11 +340,13 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { pub fn new(registry: R) -> Self { let mut counters = Vec::with_capacity(#counters_len); let mut bool_counters = Vec::with_capacity(#bool_counters_len); - let mut nominal_offsets = Vec::with_capacity(#nominal_counters_len); let mut nominal_counters = Vec::with_capacity(#nominal_counters_len); + let mut nominal_counter_offsets = Vec::with_capacity(#nominal_counters_len); let mut measures = Vec::with_capacity(#measures_len); let mut gauges = Vec::with_capacity(#gauges_len); let mut timers = Vec::with_capacity(#timers_len); + let mut nominal_timers = Vec::with_capacity(#nominal_timers_len); + let mut nominal_timer_offsets = Vec::with_capacity(#nominal_timers_len); #counters_init #bool_counters_init @@ -287,15 +354,18 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { #measures_init #gauges_init #timers_init + #nominal_timers_init Self { counters: counters.try_into().unwrap_or_else(|_| panic!("invalid len")), bool_counters: bool_counters.try_into().unwrap_or_else(|_| panic!("invalid len")), nominal_counters: nominal_counters.into(), - nominal_offsets: nominal_offsets.try_into().unwrap_or_else(|_| panic!("invalid len")), + nominal_counter_offsets: nominal_counter_offsets.try_into().unwrap_or_else(|_| panic!("invalid len")), measures: measures.try_into().unwrap_or_else(|_| panic!("invalid len")), gauges: gauges.try_into().unwrap_or_else(|_| panic!("invalid len")), timers: timers.try_into().unwrap_or_else(|_| panic!("invalid len")), + nominal_timers: nominal_timers.into(), + nominal_timer_offsets: nominal_timer_offsets.try_into().unwrap_or_else(|_| panic!("invalid len")), registry, } } @@ -339,7 +409,7 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { #[inline(always)] fn count_nominal(&self, info: usize, id: usize, value: &T) { let info = &INFO[info]; - let idx = self.nominal_offsets[id] + value.variant_idx(); + let idx = self.nominal_counter_offsets[id] + value.variant_idx(); let counter = &self.nominal_counters[idx]; counter.record(info, value.as_variant(), 1usize); } @@ -385,17 +455,29 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { let timer = &self.timers[id]; timer.record(info, value); } + + #[allow(dead_code)] + #[inline(always)] + fn time_nominal(&self, info: usize, id: usize, value: &T, duration: core::time::Duration) { + let info = &INFO[info]; + let idx = self.nominal_timer_offsets[id] + value.variant_idx(); + let counter = &self.nominal_timers[idx]; + counter.record(info, value.as_variant(), duration); + } } impl event::Subscriber for Subscriber { - // TODO include some per-connection context to get aggregates for those - type ConnectionContext = (); + type ConnectionContext = ConnectionContext; fn create_connection_context( &#mode self, - _meta: &api::ConnectionMeta, + meta: &api::ConnectionMeta, _info: &api::ConnectionInfo - ) -> Self::ConnectionContext {} + ) -> Self::ConnectionContext { + Self::ConnectionContext { + start_time: meta.timestamp, + } + } #subscriber } @@ -431,6 +513,10 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { } mod timer { #timers_probes + + pub mod nominal { + #nominal_timers_probes + } } #[derive(Default)] @@ -443,6 +529,7 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { type Measure = measure::Recorder; type Gauge = gauge::Recorder; type Timer = timer::Recorder; + type NominalTimer = timer::nominal::Recorder; #[inline] fn register_counter(&self, info: &'static Info) -> Self::Counter { @@ -473,6 +560,11 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { fn register_timer(&self, info: &'static Info) -> Self::Timer { timer::Recorder::new(info) } + + #[inline] + fn register_nominal_timer(&self, info: &'static Info, variant: &'static info::Variant) -> Self::NominalTimer { + timer::nominal::Recorder::new(info, variant) + } } ); @@ -487,6 +579,21 @@ pub fn emit(output: &Output, files: &[File]) -> TokenStream { ) } +fn metrics_iter<'a>( + metrics: &'a [Metric], +) -> Box)>> { + Box::new(metrics.iter().map(|m| (&m.name, m.unit.as_ref()))) + as Box)>> +} + +fn metrics_iter_with_unit<'a>( + metrics: &'a [MetricNoUnit], + unit: Option<&'a Ident>, +) -> Box)>> { + Box::new(metrics.iter().map(move |m| (&m.name, unit))) + as Box)>> +} + #[derive(Default)] struct InfoList { len: usize, @@ -539,7 +646,7 @@ impl ToTokens for Info { enum RegistryType { Basic, BoolCounter, - NominalCounter { nominal_offsets: TokenStream }, + Nominal { offsets: TokenStream }, } struct Registry { @@ -580,7 +687,7 @@ impl Registry { } pub fn init(&mut self) -> TokenStream { - if matches!(self.registry_type, RegistryType::NominalCounter { .. }) { + if matches!(self.registry_type, RegistryType::Nominal { .. }) { let init = &self.init; quote!({ #[allow(unused_imports)] @@ -670,7 +777,7 @@ impl Registry { #probe_defs ) } - RegistryType::NominalCounter { .. } => { + RegistryType::Nominal { .. } => { quote!( #![allow(non_snake_case)] @@ -732,7 +839,7 @@ impl Registry { fn #probe(value: #metric_ty); )); } - RegistryType::NominalCounter { nominal_offsets } => { + RegistryType::Nominal { offsets } => { let field_ty = field_ty.expect("need field type for nominal"); // trim off any generics @@ -754,7 +861,7 @@ impl Registry { count += 1; } debug_assert_ne!(count, 0, "field type needs at least one variant"); - #nominal_offsets.push(offset); + #offsets.push(offset); })); self.entries.extend(quote!( @@ -784,8 +891,8 @@ impl ToTokens for Registry { return; } - let dest = if let RegistryType::NominalCounter { nominal_offsets } = &self.registry_type { - nominal_offsets + let dest = if let RegistryType::Nominal { offsets } = &self.registry_type { + offsets } else { &self.dest }; diff --git a/quic/s2n-quic-events/src/parser.rs b/quic/s2n-quic-events/src/parser.rs index e10eb746c3..9ee92ed926 100644 --- a/quic/s2n-quic-events/src/parser.rs +++ b/quic/s2n-quic-events/src/parser.rs @@ -540,6 +540,7 @@ pub struct ContainerAttrs { pub derive_attrs: TokenStream, pub builder_derive: bool, pub builder_derive_attrs: TokenStream, + pub checkpoint: Vec, pub extra: TokenStream, } @@ -558,6 +559,7 @@ impl ContainerAttrs { derive_attrs: quote!(), builder_derive: false, builder_derive_attrs: quote!(), + checkpoint: vec![], extra: quote!(), }; @@ -583,16 +585,22 @@ impl ContainerAttrs { if let Meta::List(list) = attr.parse_args().unwrap() { list.to_tokens(&mut v.builder_derive_attrs); } + } else if path.is_ident("checkpoint") { + v.checkpoint.push(attr.parse_args().unwrap()); } else { attr.to_tokens(&mut v.extra) } } + if !v.checkpoint.is_empty() { + assert_eq!(v.subject, Subject::Connection); + } + v } } -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq)] pub enum Subject { Connection, Endpoint, @@ -727,6 +735,7 @@ pub struct FieldAttrs { pub counter: Vec, pub bool_counter: Vec, pub nominal_counter: Vec, + pub nominal_checkpoint: Vec, pub measure: Vec, pub gauge: Vec, pub timer: Vec, @@ -762,6 +771,7 @@ impl FieldAttrs { field!(counter[]); field!(bool_counter[]); field!(nominal_counter[]); + field!(nominal_checkpoint[]); field!(measure[]); field!(gauge[]); field!(timer[]); @@ -863,3 +873,24 @@ impl syn::parse::Parse for MetricNoUnit { Ok(Self { name }) } } + +#[derive(Debug)] +pub struct Checkpoint { + pub name: syn::LitStr, + pub condition: Option, +} + +impl syn::parse::Parse for Checkpoint { + fn parse(input: ParseStream) -> syn::Result { + let name = input.parse()?; + let condition = if input.peek(Token![,]) { + let _: Token![,] = input.parse()?; + let v = input.parse()?; + Some(v) + } else { + None + }; + let _: syn::parse::Nothing = input.parse()?; + Ok(Self { name, condition }) + } +} diff --git a/quic/s2n-quic/src/tests/snapshots/platform_events__client.snap b/quic/s2n-quic/src/tests/snapshots/platform_events__client.snap index 0fccbe243e..4cfd20e06d 100644 --- a/quic/s2n-quic/src/tests/snapshots/platform_events__client.snap +++ b/quic/s2n-quic/src/tests/snapshots/platform_events__client.snap @@ -2,26 +2,26 @@ source: quic/s2n-quic-core/src/event/snapshot.rs input_file: quic/s2n-quic/src/tests/platform_events.rs --- -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.000001)) } PlatformEventLoopStarted { local_address: 1.0.0.1:49153 } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.000001)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: true, application_wakeup: false } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.000001)) } PlatformRx { count: 0, syscalls: 1, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.000001)) } PlatformEventLoopSleep { timeout: None, processing_duration: 1µs } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.000001)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: false, application_wakeup: true } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.000001)) } PlatformEventLoopSleep { timeout: Some(999ms), processing_duration: 1µs } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.100000)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.100000)) } PlatformTx { count: 1, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.100000)) } PlatformRx { count: 1, syscalls: 2, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.100000)) } PlatformEventLoopSleep { timeout: Some(299.995ms), processing_duration: 1µs } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.100000)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: false, application_wakeup: true } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.100000)) } PlatformTx { count: 1, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.100000)) } PlatformEventLoopSleep { timeout: Some(299.995ms), processing_duration: 1µs } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformTx { count: 1, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformRx { count: 3, syscalls: 2, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformEventLoopSleep { timeout: Some(274.995ms), processing_duration: 1µs } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: false, application_wakeup: true } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformTx { count: 2, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformEventLoopSleep { timeout: Some(274.995ms), processing_duration: 1µs } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformTx { count: 0, syscalls: 1, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Client, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformRx { count: 0, syscalls: 1, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.000001) } PlatformEventLoopStarted { local_address: 1.0.0.1:49153 } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.000001) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: true, application_wakeup: false } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.000001) } PlatformRx { count: 0, syscalls: 1, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.000001) } PlatformEventLoopSleep { timeout: None, processing_duration: 1µs } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.000001) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: false, application_wakeup: true } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.000001) } PlatformEventLoopSleep { timeout: Some(999ms), processing_duration: 1µs } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.100000) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.100000) } PlatformTx { count: 1, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.100000) } PlatformRx { count: 1, syscalls: 2, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.100000) } PlatformEventLoopSleep { timeout: Some(299.995ms), processing_duration: 1µs } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.100000) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: false, application_wakeup: true } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.100000) } PlatformTx { count: 1, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.100000) } PlatformEventLoopSleep { timeout: Some(299.995ms), processing_duration: 1µs } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.200000) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.200000) } PlatformTx { count: 1, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.200000) } PlatformRx { count: 3, syscalls: 2, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.200000) } PlatformEventLoopSleep { timeout: Some(274.995ms), processing_duration: 1µs } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.200000) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: false, application_wakeup: true } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.200000) } PlatformTx { count: 2, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.200000) } PlatformEventLoopSleep { timeout: Some(274.995ms), processing_duration: 1µs } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.200000) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.200000) } PlatformTx { count: 0, syscalls: 1, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Client, timestamp: Timestamp(0:00:00.200000) } PlatformRx { count: 0, syscalls: 1, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } diff --git a/quic/s2n-quic/src/tests/snapshots/platform_events__server.snap b/quic/s2n-quic/src/tests/snapshots/platform_events__server.snap index 2d2427ad0d..907664bce4 100644 --- a/quic/s2n-quic/src/tests/snapshots/platform_events__server.snap +++ b/quic/s2n-quic/src/tests/snapshots/platform_events__server.snap @@ -2,24 +2,24 @@ source: quic/s2n-quic-core/src/event/snapshot.rs input_file: quic/s2n-quic/src/tests/platform_events.rs --- -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.000001)) } PlatformEventLoopStarted { local_address: 1.0.0.0:49152 } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.000001)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: true, application_wakeup: false } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.000001)) } PlatformRx { count: 0, syscalls: 1, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.000001)) } PlatformEventLoopSleep { timeout: None, processing_duration: 1µs } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.050000)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.050000)) } PlatformRx { count: 1, syscalls: 2, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.050000)) } VersionInformation { server_versions: [1], client_versions: [], chosen_version: Some(1) } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.050000)) } PlatformEventLoopSleep { timeout: Some(999ms), processing_duration: 1µs } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.150000)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.150000)) } PlatformTx { count: 1, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.150000)) } PlatformRx { count: 2, syscalls: 2, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.150000)) } VersionInformation { server_versions: [1], client_versions: [], chosen_version: Some(1) } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.150000)) } PlatformEventLoopSleep { timeout: Some(325ms), processing_duration: 1µs } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.150000)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: false, application_wakeup: true } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.150000)) } PlatformTx { count: 2, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.150000)) } PlatformEventLoopSleep { timeout: Some(325ms), processing_duration: 1µs } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformEventLoopWakeup { timeout_expired: true, rx_ready: false, tx_ready: false, application_wakeup: false } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformTx { count: 1, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformEventLoopSleep { timeout: Some(275ms), processing_duration: 1µs } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } -EndpointMeta { endpoint_type: Server, timestamp: Timestamp(Timestamp(0:00:00.200000)) } PlatformRx { count: 0, syscalls: 1, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.000001) } PlatformEventLoopStarted { local_address: 1.0.0.0:49152 } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.000001) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: true, application_wakeup: false } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.000001) } PlatformRx { count: 0, syscalls: 1, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.000001) } PlatformEventLoopSleep { timeout: None, processing_duration: 1µs } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.050000) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.050000) } PlatformRx { count: 1, syscalls: 2, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.050000) } VersionInformation { server_versions: [1], client_versions: [], chosen_version: Some(1) } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.050000) } PlatformEventLoopSleep { timeout: Some(999ms), processing_duration: 1µs } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.150000) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.150000) } PlatformTx { count: 1, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.150000) } PlatformRx { count: 2, syscalls: 2, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.150000) } VersionInformation { server_versions: [1], client_versions: [], chosen_version: Some(1) } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.150000) } PlatformEventLoopSleep { timeout: Some(325ms), processing_duration: 1µs } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.150000) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: false, tx_ready: false, application_wakeup: true } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.150000) } PlatformTx { count: 2, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.150000) } PlatformEventLoopSleep { timeout: Some(325ms), processing_duration: 1µs } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.200000) } PlatformEventLoopWakeup { timeout_expired: true, rx_ready: false, tx_ready: false, application_wakeup: false } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.200000) } PlatformTx { count: 1, syscalls: 1, blocked_syscalls: 0, total_errors: 0, dropped_errors: 0 } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.200000) } PlatformEventLoopSleep { timeout: Some(275ms), processing_duration: 1µs } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.200000) } PlatformEventLoopWakeup { timeout_expired: false, rx_ready: true, tx_ready: false, application_wakeup: false } +EndpointMeta { endpoint_type: Server, timestamp: Timestamp(0:00:00.200000) } PlatformRx { count: 0, syscalls: 1, blocked_syscalls: 1, total_errors: 0, dropped_errors: 0 }