Skip to content

Commit eaeefdb

Browse files
committed
formatting
1 parent 782a4d4 commit eaeefdb

File tree

1 file changed

+53
-26
lines changed

1 file changed

+53
-26
lines changed

opentelemetry/src/context.rs

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ mod tests {
728728
}
729729

730730
/// Tests edge cases in context stack operations. IRL these should log
731-
/// warnings, and definitely not panic.
731+
/// warnings, and definitely not panic.
732732
#[test]
733733
fn test_pop_id_edge_cases() {
734734
let mut stack = ContextStack::default();
@@ -753,7 +753,7 @@ mod tests {
753753
/// Tests stack behavior when reaching maximum capacity.
754754
/// Once we push beyond this point, we should end up with a context
755755
/// that points _somewhere_, but mutating it should not affect the current
756-
/// active context.
756+
/// active context.
757757
#[test]
758758
fn test_push_overflow() {
759759
let mut stack = ContextStack::default();
@@ -780,37 +780,52 @@ mod tests {
780780

781781
/// Tests that:
782782
/// 1. Parent context values are properly propagated to async operations
783-
/// 2. Values added during async operations do not affect parent context
783+
/// 2. Values added during async operations do not affect parent context
784784
#[tokio::test]
785785
async fn test_async_context_propagation() {
786786
// Set up initial context with ValueA
787787
let parent_cx = Context::new().with_value(ValueA(42));
788-
788+
789789
// Create and run async operation with the parent context
790790
async {
791791
// Verify we can see the parent context's value
792-
assert_eq!(Context::current().get::<ValueA>(), Some(&ValueA(42)),
793-
"Parent context value should be available in async operation");
794-
792+
assert_eq!(
793+
Context::current().get::<ValueA>(),
794+
Some(&ValueA(42)),
795+
"Parent context value should be available in async operation"
796+
);
797+
795798
// Create new context with both values
796799
let cx_with_both = Context::current().with_value(ValueB(24));
797-
800+
798801
// Run nested async operation with both values
799802
async {
800803
// Verify both values are available
801-
assert_eq!(Context::current().get::<ValueA>(), Some(&ValueA(42)),
802-
"Parent value should still be available after adding new value");
803-
assert_eq!(Context::current().get::<ValueB>(), Some(&ValueB(24)),
804-
"New value should be available in async operation");
805-
804+
assert_eq!(
805+
Context::current().get::<ValueA>(),
806+
Some(&ValueA(42)),
807+
"Parent value should still be available after adding new value"
808+
);
809+
assert_eq!(
810+
Context::current().get::<ValueB>(),
811+
Some(&ValueB(24)),
812+
"New value should be available in async operation"
813+
);
814+
806815
// Do some async work to simulate real-world scenario
807816
sleep(Duration::from_millis(10)).await;
808-
817+
809818
// Values should still be available after async work
810-
assert_eq!(Context::current().get::<ValueA>(), Some(&ValueA(42)),
811-
"Parent value should persist across await points");
812-
assert_eq!(Context::current().get::<ValueB>(), Some(&ValueB(24)),
813-
"New value should persist across await points");
819+
assert_eq!(
820+
Context::current().get::<ValueA>(),
821+
Some(&ValueA(42)),
822+
"Parent value should persist across await points"
823+
);
824+
assert_eq!(
825+
Context::current().get::<ValueB>(),
826+
Some(&ValueB(24)),
827+
"New value should persist across await points"
828+
);
814829
}
815830
.with_context(cx_with_both)
816831
.await;
@@ -820,15 +835,27 @@ mod tests {
820835

821836
// After async operation completes:
822837
// 1. Parent context should be unchanged
823-
assert_eq!(parent_cx.get::<ValueA>(), Some(&ValueA(42)),
824-
"Parent context should be unchanged");
825-
assert_eq!(parent_cx.get::<ValueB>(), None,
826-
"Parent context should not see values added in async operation");
838+
assert_eq!(
839+
parent_cx.get::<ValueA>(),
840+
Some(&ValueA(42)),
841+
"Parent context should be unchanged"
842+
);
843+
assert_eq!(
844+
parent_cx.get::<ValueB>(),
845+
None,
846+
"Parent context should not see values added in async operation"
847+
);
827848

828849
// 2. Current context should be back to default
829-
assert_eq!(Context::current().get::<ValueA>(), None,
830-
"Current context should be back to default");
831-
assert_eq!(Context::current().get::<ValueB>(), None,
832-
"Current context should not have async operation's values");
850+
assert_eq!(
851+
Context::current().get::<ValueA>(),
852+
None,
853+
"Current context should be back to default"
854+
);
855+
assert_eq!(
856+
Context::current().get::<ValueB>(),
857+
None,
858+
"Current context should not have async operation's values"
859+
);
833860
}
834861
}

0 commit comments

Comments
 (0)