@@ -207,14 +207,12 @@ where
207207 Ok ( ( ) )
208208 }
209209
210- fn write_span_info < S : Subscriber + for < ' span > LookupSpan < ' span > + fmt:: Debug > (
211- & self ,
212- id : & tracing:: Id ,
213- ctx : & Context < S > ,
214- style : SpanMode ,
215- ) {
210+ fn write_span_info < S > ( & self , id : & tracing:: Id , ctx : & Context < S > , style : SpanMode )
211+ where
212+ S : Subscriber + for < ' span > LookupSpan < ' span > + fmt:: Debug ,
213+ {
216214 let span = ctx
217- . span ( & id)
215+ . span ( id)
218216 . expect ( "in on_enter/on_exit but span does not exist" ) ;
219217 let ext = span. extensions ( ) ;
220218 let data = ext. get :: < Data > ( ) . expect ( "span does not have data" ) ;
@@ -223,6 +221,9 @@ where
223221 let bufs = & mut * guard;
224222 let mut current_buf = & mut bufs. current_buf ;
225223
224+ // todo(david): i'm going to keep this for a bit since there's an odd discrepancy in counting
225+ // that i don't want to resolve rn lol
226+ #[ allow( deprecated) ]
226227 let indent = ctx. scope ( ) . count ( ) ;
227228
228229 if self . config . verbose_entry || matches ! ( style, SpanMode :: Open { .. } | SpanMode :: Event ) {
@@ -280,10 +281,11 @@ where
280281 let span = ctx. span ( id) . expect ( "in new_span but span does not exist" ) ;
281282 span. extensions_mut ( ) . insert ( data) ;
282283 if self . config . verbose_exit {
283- if let Some ( span) = ctx . scope ( ) . last ( ) {
284+ if let Some ( span) = span . parent ( ) {
284285 self . write_span_info ( & span. id ( ) , & ctx, SpanMode :: PreOpen ) ;
285286 }
286287 }
288+
287289 self . write_span_info (
288290 id,
289291 & ctx,
@@ -301,7 +303,9 @@ where
301303 // printing the indentation
302304 let indent = if ctx. current_span ( ) . id ( ) . is_some ( ) {
303305 // size hint isn't implemented on Scope.
304- ctx. scope ( ) . count ( )
306+ ctx. event_scope ( event)
307+ . expect ( "Unable to get span scope; this is a bug" )
308+ . count ( )
305309 } else {
306310 0
307311 } ;
@@ -378,8 +382,9 @@ where
378382 verbose : self . config . verbose_exit ,
379383 } ,
380384 ) ;
385+
381386 if self . config . verbose_exit {
382- if let Some ( span) = ctx. scope ( ) . last ( ) {
387+ if let Some ( span) = ctx. span ( & id ) . and_then ( |span| span . parent ( ) ) {
383388 self . write_span_info ( & span. id ( ) , & ctx, SpanMode :: PostClose ) ;
384389 }
385390 }
0 commit comments