Skip to content

Commit 0aa6c8e

Browse files
authored
fix(test): fix test_concurrent_structured_logging_isolation (#1121)
* fix(test): fix feature flag for test_concurrent_structured_logging_isolation * fix: remove traced_test * fix: use thread-local subscriber in logging isolation test Replace set_global_default with set_default to avoid "global default trace dispatcher has already been set" errors when tests run in the same process. * docs: note current-thread requirement for logging isolation test
1 parent 7f66cde commit 0aa6c8e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lambda-runtime/src/runtime.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -935,10 +935,10 @@ mod endpoint_tests {
935935
Ok(())
936936
}
937937

938-
#[tokio::test]
939938
#[cfg(feature = "concurrency-tokio")]
940-
#[traced_test]
941-
#[cfg(feature = "tokio-concurrent-runtime")]
939+
// Must be current-thread (the default) so the thread-local tracing
940+
// subscriber set via `set_default` propagates to spawned tasks.
941+
#[tokio::test]
942942
async fn test_concurrent_structured_logging_isolation() -> Result<(), Error> {
943943
use std::collections::HashSet;
944944
use tracing::info;
@@ -947,7 +947,7 @@ mod endpoint_tests {
947947

948948
let storage = SharedStorage::default();
949949
let subscriber = tracing_subscriber::registry().with(CaptureLayer::new(&storage));
950-
tracing::subscriber::set_global_default(subscriber).unwrap();
950+
let _guard = tracing::subscriber::set_default(subscriber);
951951

952952
let request_count = Arc::new(AtomicUsize::new(0));
953953
let done = Arc::new(tokio::sync::Notify::new());

0 commit comments

Comments
 (0)