mirror of
https://github.com/openai/codex.git
synced 2026-09-17 12:23:33 +00:00
Stabilize network policy event capture in concurrent tests (#36779)
## Why Concurrent tests without a tracing subscriber can cache the network policy callsite as disabled, causing event-capture tests to miss events. ## What changed - Attach the test event collector directly to the captured future. - Rebuild the tracing interest cache before running that future while keeping tracing out of its single-subscriber fast path. GitOrigin-RevId: 20d6160d26f56ad9fd86afd5107cb4313a5fce73
This commit is contained in:
committed by
copyberry
parent
78306a32af
commit
136f75e7b7
@@ -407,6 +407,7 @@ pub(crate) mod test_support {
|
||||
use tracing::Subscriber;
|
||||
use tracing::field::Field;
|
||||
use tracing::field::Visit;
|
||||
use tracing::instrument::WithSubscriber;
|
||||
use tracing::span::Attributes;
|
||||
use tracing::span::Record;
|
||||
use tracing::subscriber::Interest;
|
||||
@@ -531,8 +532,15 @@ pub(crate) mod test_support {
|
||||
Fut: Future<Output = T>,
|
||||
{
|
||||
let collector = EventCollector::default();
|
||||
let _guard = tracing::subscriber::set_default(collector.clone());
|
||||
let output = f().await;
|
||||
// Keep tracing out of its single-subscriber fast path: concurrent tests
|
||||
// without a subscriber can otherwise cache this callsite as disabled.
|
||||
let _interest_dispatch = tracing::Dispatch::new(collector.clone());
|
||||
let output = async {
|
||||
tracing::callsite::rebuild_interest_cache();
|
||||
f().await
|
||||
}
|
||||
.with_subscriber(collector.clone())
|
||||
.await;
|
||||
let events = collector.events();
|
||||
(output, events)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user