@@ -207,14 +207,12 @@ where
207
207
Ok ( ( ) )
208
208
}
209
209
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
+ {
216
214
let span = ctx
217
- . span ( & id)
215
+ . span ( id)
218
216
. expect ( "in on_enter/on_exit but span does not exist" ) ;
219
217
let ext = span. extensions ( ) ;
220
218
let data = ext. get :: < Data > ( ) . expect ( "span does not have data" ) ;
@@ -223,6 +221,9 @@ where
223
221
let bufs = & mut * guard;
224
222
let mut current_buf = & mut bufs. current_buf ;
225
223
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) ]
226
227
let indent = ctx. scope ( ) . count ( ) ;
227
228
228
229
if self . config . verbose_entry || matches ! ( style, SpanMode :: Open { .. } | SpanMode :: Event ) {
@@ -280,10 +281,11 @@ where
280
281
let span = ctx. span ( id) . expect ( "in new_span but span does not exist" ) ;
281
282
span. extensions_mut ( ) . insert ( data) ;
282
283
if self . config . verbose_exit {
283
- if let Some ( span) = ctx . scope ( ) . last ( ) {
284
+ if let Some ( span) = span . parent ( ) {
284
285
self . write_span_info ( & span. id ( ) , & ctx, SpanMode :: PreOpen ) ;
285
286
}
286
287
}
288
+
287
289
self . write_span_info (
288
290
id,
289
291
& ctx,
@@ -301,7 +303,9 @@ where
301
303
// printing the indentation
302
304
let indent = if ctx. current_span ( ) . id ( ) . is_some ( ) {
303
305
// 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 ( )
305
309
} else {
306
310
0
307
311
} ;
@@ -378,8 +382,9 @@ where
378
382
verbose : self . config . verbose_exit ,
379
383
} ,
380
384
) ;
385
+
381
386
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 ( ) ) {
383
388
self . write_span_info ( & span. id ( ) , & ctx, SpanMode :: PostClose ) ;
384
389
}
385
390
}
0 commit comments