@@ -27,38 +27,54 @@ pub struct Builder<Sub: event::Subscriber> {
2727 pub app_queue_time : Option < Timestamp > ,
2828}
2929
30+ /// Carries timestamps of events before the stream is returned to the application in accept().
31+ #[ non_exhaustive]
32+ pub struct AcceptInfo {
33+ /// How long the stream spent inside the dcQUIC acceptor before being enqueued for the
34+ /// application.
35+ pub dc_quic_accept_time : Duration ,
36+ /// How long the stream spent enqueued for the application.
37+ pub app_queue_sojourn_time : Duration ,
38+ }
39+
3040impl < Sub > Builder < Sub >
3141where
3242 Sub : event:: Subscriber ,
3343{
3444 /// Builds the stream and emits an event indicating that the stream was built
3545 #[ inline]
36- pub ( crate ) fn accept ( self ) -> io:: Result < ( Stream < Sub > , Duration ) > {
37- let sojourn_time = {
38- let remote_address = self . shared . remote_addr ( ) ;
39- let remote_address = & remote_address;
40- let creds = self . shared . credentials ( ) ;
41- let credential_id = & * creds. id ;
42- let stream_id = creds. key_id . as_u64 ( ) ;
43- let now = self . shared . common . clock . get_time ( ) ;
44- let total_sojourn_time = now. saturating_duration_since ( self . kernel_start_time ) ;
45- let queue_sojourn_time =
46- now. saturating_duration_since ( self . app_queue_time . expect ( "set by accept_stream" ) ) ;
47-
48- self . shared
49- . endpoint_publisher ( now)
50- . on_acceptor_stream_dequeued ( event:: builder:: AcceptorStreamDequeued {
51- remote_address,
52- credential_id,
53- stream_id,
54- sojourn_time : total_sojourn_time,
55- queue_sojourn_time,
56- } ) ;
57-
58- queue_sojourn_time
59- } ;
60-
61- self . build ( ) . map ( |stream| ( stream, sojourn_time) )
46+ pub ( crate ) fn accept ( self ) -> io:: Result < ( Stream < Sub > , AcceptInfo ) > {
47+ let kernel_start_time = self . kernel_start_time ;
48+ let app_queue_time = self . app_queue_time . expect ( "set by accept_stream" ) ;
49+ let remote_address = self . shared . remote_addr ( ) ;
50+ let remote_address = & remote_address;
51+ let creds = self . shared . credentials ( ) ;
52+ let credential_id = & * creds. id ;
53+ let stream_id = creds. key_id . as_u64 ( ) ;
54+ let now = self . shared . common . clock . get_time ( ) ;
55+ let total_sojourn_time = now. saturating_duration_since ( self . kernel_start_time ) ;
56+ let queue_sojourn_time = now. saturating_duration_since ( app_queue_time) ;
57+
58+ self . shared
59+ . endpoint_publisher ( now)
60+ . on_acceptor_stream_dequeued ( event:: builder:: AcceptorStreamDequeued {
61+ remote_address,
62+ credential_id,
63+ stream_id,
64+ sojourn_time : total_sojourn_time,
65+ queue_sojourn_time,
66+ } ) ;
67+
68+ self . build ( ) . map ( |stream| {
69+ (
70+ stream,
71+ AcceptInfo {
72+ dc_quic_accept_time : app_queue_time
73+ . saturating_duration_since ( kernel_start_time) ,
74+ app_queue_sojourn_time : now. saturating_duration_since ( app_queue_time) ,
75+ } ,
76+ )
77+ } )
6278 }
6379
6480 #[ inline]
0 commit comments