@@ -880,7 +880,7 @@ where
880
880
. get_mut :: < OtelData > ( )
881
881
. map ( |data| self . with_started_cx ( data, & |cx| cx. clone ( ) ) )
882
882
} )
883
- . unwrap_or_else ( || OtelContext :: current ( ) )
883
+ . unwrap_or_else ( OtelContext :: current)
884
884
}
885
885
} else {
886
886
OtelContext :: default ( )
@@ -896,8 +896,8 @@ where
896
896
/// * `dispatch` - A reference to the tracing dispatch, used to access the subscriber
897
897
/// * `id` - The ID of the span to look up
898
898
/// * `f` - A callback function that receives a mutable reference to the span's `OtelData`
899
- /// This callback is used to manipulate or extract information from the OpenTelemetry context
900
- /// associated with the tracing span
899
+ /// This callback is used to manipulate or extract information from the OpenTelemetry context
900
+ /// associated with the tracing span
901
901
///
902
902
fn get_context ( dispatch : & tracing:: Dispatch , id : & span:: Id , f : & mut dyn FnMut ( & mut OtelData ) ) {
903
903
let subscriber = dispatch
@@ -1315,28 +1315,32 @@ where
1315
1315
} ) = otel_data
1316
1316
{
1317
1317
// Append busy/idle timings when enabled.
1318
- let timings = timings. and_then ( |timings| {
1318
+ let timings = timings. map ( |timings| {
1319
1319
let busy_ns = Key :: new ( "busy_ns" ) ;
1320
1320
let idle_ns = Key :: new ( "idle_ns" ) ;
1321
1321
1322
- Some ( vec ! [
1322
+ vec ! [
1323
1323
KeyValue :: new( busy_ns, timings. busy) ,
1324
1324
KeyValue :: new( idle_ns, timings. idle) ,
1325
- ] )
1325
+ ]
1326
1326
} ) ;
1327
1327
1328
1328
if let Some ( builder) = builder {
1329
1329
// Don't create the context here just to get a SpanRef since it's costly
1330
1330
let mut span = builder. start_with_context ( & self . tracer , & parent_cx) ;
1331
- timings. map ( |timings| span. set_attributes ( timings) ) ;
1331
+ if let Some ( timings) = timings {
1332
+ span. set_attributes ( timings)
1333
+ } ;
1332
1334
if let Some ( end_time) = end_time {
1333
1335
span. end_with_timestamp ( end_time) ;
1334
1336
} else {
1335
1337
span. end ( ) ;
1336
1338
}
1337
1339
} else {
1338
1340
let span = parent_cx. span ( ) ;
1339
- timings. map ( |timings| span. set_attributes ( timings) ) ;
1341
+ if let Some ( timings) = timings {
1342
+ span. set_attributes ( timings)
1343
+ } ;
1340
1344
end_time. map_or_else ( || span. end ( ) , |end_time| span. end_with_timestamp ( end_time) ) ;
1341
1345
} ;
1342
1346
}
0 commit comments