@@ -461,7 +461,7 @@ impl ContextStack {
461461 // and cannot be popped, and the overflow position is invalid, so do
462462 // nothing.
463463 otel_warn ! (
464- name: "Context.PopInvalidPosition " ,
464+ name: "Context.OutOfOrderDrop " ,
465465 position = pos,
466466 message = if pos == ContextStack :: BASE_POS {
467467 "Attempted to pop the base context which is not allowed"
@@ -783,27 +783,27 @@ mod tests {
783783 /// 2. Values added during async operations do not affect parent context
784784 #[ tokio:: test]
785785 async fn test_async_context_propagation ( ) {
786- // Set up initial context with ValueA
787- let parent_cx = Context :: new ( ) . with_value ( ValueA ( 42 ) ) ;
788786
789- // Create and run async operation with the parent context
790- async {
787+ // A nested async operation we'll use to test propagation
788+ async fn nested_operation ( ) {
791789 // Verify we can see the parent context's value
792790 assert_eq ! (
793791 Context :: current( ) . get:: <ValueA >( ) ,
794792 Some ( & ValueA ( 42 ) ) ,
795793 "Parent context value should be available in async operation"
796794 ) ;
797795
798- // Create new context with both values
799- let cx_with_both = Context :: current ( ) . with_value ( ValueB ( 24 ) ) ;
796+ // Create new context
797+ let cx_with_both = Context :: current ( )
798+ . with_value ( ValueA ( 43 ) ) // override ValueA
799+ . with_value ( ValueB ( 24 ) ) ; // Add new ValueB
800800
801801 // Run nested async operation with both values
802802 async {
803803 // Verify both values are available
804804 assert_eq ! (
805805 Context :: current( ) . get:: <ValueA >( ) ,
806- Some ( & ValueA ( 42 ) ) ,
806+ Some ( & ValueA ( 43 ) ) ,
807807 "Parent value should still be available after adding new value"
808808 ) ;
809809 assert_eq ! (
@@ -818,7 +818,7 @@ mod tests {
818818 // Values should still be available after async work
819819 assert_eq ! (
820820 Context :: current( ) . get:: <ValueA >( ) ,
821- Some ( & ValueA ( 42 ) ) ,
821+ Some ( & ValueA ( 43 ) ) ,
822822 "Parent value should persist across await points"
823823 ) ;
824824 assert_eq ! (
@@ -827,11 +827,15 @@ mod tests {
827827 "New value should persist across await points"
828828 ) ;
829829 }
830- . with_context ( cx_with_both)
831- . await ;
830+ . with_context ( cx_with_both)
831+ . await ;
832832 }
833- . with_context ( parent_cx. clone ( ) ) // Propagate the parent context to the async operation
834- . await ;
833+
834+ // Set up initial context with ValueA
835+ let parent_cx = Context :: new ( ) . with_value ( ValueA ( 42 ) ) ;
836+
837+ // Create and run async operation with the parent context explicitly propagated
838+ nested_operation ( ) . with_context ( parent_cx. clone ( ) ) . await ;
835839
836840 // After async operation completes:
837841 // 1. Parent context should be unchanged
0 commit comments