diff --git a/netwerk/metrics.yaml b/netwerk/metrics.yaml index 4e476ffcd3d9..a28f0499a4a1 100644 --- a/netwerk/metrics.yaml +++ b/netwerk/metrics.yaml @@ -8193,3 +8193,366 @@ com expires : never +http_3_udp_datagram_segment_size_sent +: +type +: +memory_distribution +memory_unit +: +byte +description +: +> +HTTP3 +UDP +datagram +segment +size +sent +. +bugs +: +- +https +: +/ +/ +bugzilla +. +mozilla +. +org +/ +show_bug +. +cgi +? +id += +1906853 +data_reviews +: +- +https +: +/ +/ +bugzilla +. +mozilla +. +org +/ +show_bug +. +cgi +? +id += +1906853 +data_sensitivity +: +- +technical +notification_emails +: +- +necko +mozilla +. +com +- +minden +mozilla +. +com +expires +: +never +http_3_udp_datagram_segment_size_received +: +type +: +memory_distribution +memory_unit +: +byte +description +: +> +HTTP3 +UDP +datagram +size +received +. +bugs +: +- +https +: +/ +/ +bugzilla +. +mozilla +. +org +/ +show_bug +. +cgi +? +id += +1906853 +data_reviews +: +- +https +: +/ +/ +bugzilla +. +mozilla +. +org +/ +show_bug +. +cgi +? +id += +1906853 +data_sensitivity +: +- +technical +notification_emails +: +- +necko +mozilla +. +com +- +minden +mozilla +. +com +expires +: +never +http_3_udp_datagram_size_received +: +type +: +memory_distribution +memory_unit +: +byte +description +: +> +HTTP3 +UDP +datagram +size +received +. +bugs +: +- +https +: +/ +/ +bugzilla +. +mozilla +. +org +/ +show_bug +. +cgi +? +id += +1906853 +data_reviews +: +- +https +: +/ +/ +bugzilla +. +mozilla +. +org +/ +show_bug +. +cgi +? +id += +1906853 +data_sensitivity +: +- +technical +notification_emails +: +- +necko +mozilla +. +com +- +minden +mozilla +. +com +expires +: +never +http_3_udp_datagram_segments_received +: +type +: +custom_distribution +unit +: +integer +range_min +: +0 +# +Maximum +number +of +UDP +segments +per +datagram +. +# +# +See +e +. +g +. +Linux +https +: +/ +/ +github +. +com +/ +torvalds +/ +linux +/ +blob +/ +20371ba120635d9ab7fc7670497105af8f33eb08 +/ +include +/ +linux +/ +udp +. +h +# +L111 +. +range_max +: +128 +bucket_count +: +100 +histogram_type +: +exponential +description +: +> +HTTP3 +UDP +number +of +segments +per +datagram +received +. +bugs +: +- +https +: +/ +/ +bugzilla +. +mozilla +. +org +/ +show_bug +. +cgi +? +id += +1906853 +data_reviews +: +- +https +: +/ +/ +bugzilla +. +mozilla +. +org +/ +show_bug +. +cgi +? +id += +1906853 +data_sensitivity +: +- +technical +notification_emails +: +- +necko +mozilla +. +com +- +minden +mozilla +. +com +expires +: +never diff --git a/netwerk/socket/neqo_glue/src/lib.rs b/netwerk/socket/neqo_glue/src/lib.rs index ca0f221d5b45..761e4829ec12 100644 --- a/netwerk/socket/neqo_glue/src/lib.rs +++ b/netwerk/socket/neqo_glue/src/lib.rs @@ -307,6 +307,9 @@ RefCounted RefPtr } ; +mod +metrics +; # [ repr @@ -365,6 +368,23 @@ record_stats_in_glean ( ) ; +metrics +: +: +METRICS +. +with_borrow_mut +( +| +m +| +m +. +sync_to_glean +( +) +) +; } } # @@ -2904,38 +2924,15 @@ is_empty break ; } -bytes_read -+ -= -dgrams -. -iter -( -) -. -map -( -| -d -| -d -. -len -( -) -) -. +let +mut sum -: -: -< -usize -> -( -) += +0 ; -if -! +let +ecn_enabled += static_prefs : : @@ -2952,7 +2949,7 @@ http3 ecn " ) -{ +; for dgram in @@ -2960,6 +2957,10 @@ in mut dgrams { +if +! +ecn_enabled +{ dgram . set_tos @@ -2973,7 +2974,89 @@ default ) ; } +metrics +: +: +METRICS +. +with_borrow_mut +( +| +m +| +m +. +datagram_segment_size_received +. +sample +( +dgram +. +len +( +) +) +) +; +sum ++ += +dgram +. +len +( +) +; } +metrics +: +: +METRICS +. +with_borrow_mut +( +| +m +| +m +. +datagram_size_received +. +sample +( +sum +) +) +; +metrics +: +: +METRICS +. +with_borrow_mut +( +| +m +| +m +. +datagram_segments_received +. +sample +( +dgrams +. +len +( +) +) +) +; +bytes_read ++ += +sum +; conn . conn @@ -3854,6 +3937,30 @@ len ( ) ; +metrics +: +: +METRICS +. +with_borrow_mut +( +| +m +| +m +. +datagram_segment_size_sent +. +sample +( +dg +. +len +( +) +) +) +; } Output : diff --git a/netwerk/socket/neqo_glue/src/metrics.rs b/netwerk/socket/neqo_glue/src/metrics.rs new file mode 100644 index 000000000000..c31241424036 --- /dev/null +++ b/netwerk/socket/neqo_glue/src/metrics.rs @@ -0,0 +1,545 @@ +use +std +: +: +cell +: +: +RefCell +; +# +[ +cfg +( +not +( +target_os += +" +android +" +) +) +] +use +std +: +: +convert +: +: +{ +TryFrom +TryInto +} +; +use +firefox_on_glean +: +: +metrics +: +: +networking +as +glean +; +# +[ +cfg +( +not +( +target_os += +" +android +" +) +) +] +const +BUFFER_SIZE +: +usize += +1024 +; +std +: +: +thread_local +! +{ +pub +static +METRICS +: +RefCell +< +BufferedMetrics +> += +RefCell +: +: +new +( +BufferedMetrics +: +: +default +( +) +) +; +} +# +[ +allow +( +dead_code +) +] +pub +struct +BufferedMetric +< +S +> +{ +buffer +: +Vec +< +S +> +sync +: +fn +( +Vec +< +S +> +) +} +impl +< +S +> +BufferedMetric +< +S +> +{ +fn +new +( +f +: +fn +( +Vec +< +S +> +) +) +- +> +Self +{ +Self +{ +buffer +: +vec +! +[ +] +sync +: +f +} +} +} +# +[ +cfg +( +not +( +target_os += +" +android +" +) +) +] +impl +< +S +: +TryFrom +< +usize +> +> +BufferedMetric +< +S +> +{ +pub +fn +sample +( +& +mut +self +sample +: +usize +) +{ +let +Ok +( +sample +) += +sample +. +try_into +( +) +else +{ +neqo_common +: +: +qdebug +! +( +" +failed +to +convert +{ +sample +} +to +metric +' +s +sample +type +" +) +; +return +; +} +; +self +. +buffer +. +push +( +sample +) +; +if +self +. +buffer +. +len +( +) += += +BUFFER_SIZE +{ +self +. +sync_to_glean +( +) +; +} +} +fn +sync_to_glean +( +& +mut +self +) +{ +if +! +self +. +buffer +. +is_empty +( +) +{ +( +self +. +sync +) +( +std +: +: +mem +: +: +take +( +& +mut +self +. +buffer +) +) +; +} +} +} +# +[ +cfg +( +target_os += +" +android +" +) +] +impl +< +S +> +BufferedMetric +< +S +> +{ +pub +fn +sample +( +& +mut +self +_sample +: +usize +) +{ +} +fn +sync_to_glean +( +& +mut +self +) +{ +} +} +pub +struct +BufferedMetrics +{ +pub +datagram_segment_size_sent +: +BufferedMetric +< +u64 +> +pub +datagram_segment_size_received +: +BufferedMetric +< +u64 +> +pub +datagram_size_received +: +BufferedMetric +< +u64 +> +pub +datagram_segments_received +: +BufferedMetric +< +i64 +> +} +impl +Default +for +BufferedMetrics +{ +fn +default +( +) +- +> +Self +{ +Self +{ +datagram_segment_size_sent +: +BufferedMetric +: +: +new +( +| +samples +| +{ +glean +: +: +http_3_udp_datagram_segment_size_sent +. +accumulate_samples +( +samples +) +} +) +datagram_segment_size_received +: +BufferedMetric +: +: +new +( +| +samples +| +{ +glean +: +: +http_3_udp_datagram_segment_size_received +. +accumulate_samples +( +samples +) +} +) +datagram_size_received +: +BufferedMetric +: +: +new +( +| +samples +| +{ +glean +: +: +http_3_udp_datagram_size_received +. +accumulate_samples +( +samples +) +} +) +datagram_segments_received +: +BufferedMetric +: +: +new +( +| +samples +| +{ +glean +: +: +http_3_udp_datagram_segments_received +. +accumulate_samples_signed +( +samples +) +} +) +} +} +} +impl +BufferedMetrics +{ +pub +fn +sync_to_glean +( +& +mut +self +) +{ +self +. +datagram_segment_size_sent +. +sync_to_glean +( +) +; +self +. +datagram_segment_size_received +. +sync_to_glean +( +) +; +self +. +datagram_size_received +. +sync_to_glean +( +) +; +self +. +datagram_segments_received +. +sync_to_glean +( +) +; +} +}