@@ -25,7 +25,7 @@ use tracing_core::{
2525} ;
2626use tracing_subscriber:: {
2727 layer:: Context ,
28- registry:: { Extensions , LookupSpan , SpanRef } ,
28+ registry:: { Extensions , LookupSpan } ,
2929 Layer ,
3030} ;
3131
@@ -789,87 +789,59 @@ where
789789 }
790790
791791 fn on_enter ( & self , id : & span:: Id , cx : Context < ' _ , S > ) {
792- fn update < S : Subscriber + for < ' a > LookupSpan < ' a > > (
793- span : & SpanRef < S > ,
794- at : Option < Instant > ,
795- ) -> Option < Instant > {
792+ if let Some ( span) = cx. span ( id) {
793+ let now = Instant :: now ( ) ;
796794 let exts = span. extensions ( ) ;
797795 // if the span we are entering is a task or async op, record the
798796 // poll stats.
799797 if let Some ( stats) = exts. get :: < Arc < stats:: TaskStats > > ( ) {
800- let at = at. unwrap_or_else ( Instant :: now) ;
801- stats. start_poll ( at) ;
802- Some ( at)
798+ stats. start_poll ( now) ;
803799 } else if let Some ( stats) = exts. get :: < Arc < stats:: AsyncOpStats > > ( ) {
804- let at = at. unwrap_or_else ( Instant :: now) ;
805- stats. start_poll ( at) ;
806- Some ( at)
807- // otherwise, is the span a resource? in that case, we also want
808- // to enter it, although we don't care about recording poll
809- // stats.
800+ stats. start_poll ( now) ;
810801 } else if exts. get :: < Arc < stats:: ResourceStats > > ( ) . is_some ( ) {
811- Some ( at. unwrap_or_else ( Instant :: now) )
802+ // otherwise, is the span a resource? in that case, we also want
803+ // to enter it, although we don't care about recording poll
804+ // stats.
812805 } else {
813- None
814- }
815- }
806+ return ;
807+ } ;
816808
817- if let Some ( span) = cx. span ( id) {
818- if let Some ( now) = update ( & span, None ) {
819- if let Some ( parent) = span. parent ( ) {
820- update ( & parent, Some ( now) ) ;
821- }
822- self . current_spans
823- . get_or_default ( )
824- . borrow_mut ( )
825- . push ( id. clone ( ) ) ;
826-
827- self . record ( || record:: Event :: Enter {
828- id : id. into_u64 ( ) ,
829- at : self . base_time . to_system_time ( now) ,
830- } ) ;
831- }
809+ self . current_spans
810+ . get_or_default ( )
811+ . borrow_mut ( )
812+ . push ( id. clone ( ) ) ;
813+
814+ self . record ( || record:: Event :: Enter {
815+ id : id. into_u64 ( ) ,
816+ at : self . base_time . to_system_time ( now) ,
817+ } ) ;
832818 }
833819 }
834820
835821 fn on_exit ( & self , id : & span:: Id , cx : Context < ' _ , S > ) {
836- fn update < S : Subscriber + for < ' a > LookupSpan < ' a > > (
837- span : & SpanRef < S > ,
838- at : Option < Instant > ,
839- ) -> Option < Instant > {
822+ if let Some ( span) = cx. span ( id) {
840823 let exts = span. extensions ( ) ;
824+ let now = Instant :: now ( ) ;
841825 // if the span we are entering is a task or async op, record the
842826 // poll stats.
843827 if let Some ( stats) = exts. get :: < Arc < stats:: TaskStats > > ( ) {
844- let at = at. unwrap_or_else ( Instant :: now) ;
845- stats. end_poll ( at) ;
846- Some ( at)
828+ stats. end_poll ( now) ;
847829 } else if let Some ( stats) = exts. get :: < Arc < stats:: AsyncOpStats > > ( ) {
848- let at = at. unwrap_or_else ( Instant :: now) ;
849- stats. end_poll ( at) ;
850- Some ( at)
830+ stats. end_poll ( now) ;
831+ } else if exts. get :: < Arc < stats:: ResourceStats > > ( ) . is_some ( ) {
851832 // otherwise, is the span a resource? in that case, we also want
852833 // to enter it, although we don't care about recording poll
853834 // stats.
854- } else if exts. get :: < Arc < stats:: ResourceStats > > ( ) . is_some ( ) {
855- Some ( at. unwrap_or_else ( Instant :: now) )
856835 } else {
857- None
858- }
859- }
836+ return ;
837+ } ;
860838
861- if let Some ( span) = cx. span ( id) {
862- if let Some ( now) = update ( & span, None ) {
863- if let Some ( parent) = span. parent ( ) {
864- update ( & parent, Some ( now) ) ;
865- }
866- self . current_spans . get_or_default ( ) . borrow_mut ( ) . pop ( id) ;
839+ self . current_spans . get_or_default ( ) . borrow_mut ( ) . pop ( id) ;
867840
868- self . record ( || record:: Event :: Exit {
869- id : id. into_u64 ( ) ,
870- at : self . base_time . to_system_time ( now) ,
871- } ) ;
872- }
841+ self . record ( || record:: Event :: Exit {
842+ id : id. into_u64 ( ) ,
843+ at : self . base_time . to_system_time ( now) ,
844+ } ) ;
873845 }
874846 }
875847
0 commit comments