mirror of
https://github.com/openai/codex.git
synced 2026-11-24 15:21:20 +00:00
Reload app-server telemetry after account changes (#37339)
## Why An account change can select different OpenTelemetry collector settings. The long-running app server needs to stop exporting telemetry with the previous account's configuration. ## What changed - Rebuild and install the log, trace, and metrics exporters when authentication changes, and shut down the previous provider without blocking the app server. - Make cached global metrics clients and the tracing layer follow the replacement provider so existing callers continue exporting through the current account's configuration. - Clear the cached cloud configuration loader after login and logout so telemetry reloads from the new account context. ## Testing - Add an app-server integration test that switches accounts and verifies logs, traces, and metrics reach the new collector while trace context is preserved. - Add a metrics test covering cached clients after provider replacement. GitOrigin-RevId: a74359777a35edbee5bbe0b2baccc155074cb172
This commit is contained in:
1 parent
842547640e
commit
d9eac10406
9 files changed
+437
-41
No files matched your search
@@ -111,6 +111,7 @@ mod mcp_refresh;
|
||||
mod message_processor;
|
||||
mod models;
|
||||
mod models_refresh_worker;
|
||||
mod otel_reloader;
|
||||
mod outgoing_message;
|
||||
mod request_processors;
|
||||
mod request_serialization;
|
||||
@@ -667,15 +668,13 @@ pub async fn run_main_with_transport_options(
|
||||
let log_db_layer = log_db
|
||||
.clone()
|
||||
.map(|layer| layer.with_filter(log_db::default_filter()));
|
||||
let otel_logger_layer = otel.as_ref().and_then(|o| o.logger_layer());
|
||||
let otel_tracing_layer = otel.as_ref().and_then(|o| o.tracing_layer());
|
||||
let (otel_layers, otel_logger_reload_handle) = otel_reloader::layers(otel.as_ref());
|
||||
let _ = tracing_subscriber::registry()
|
||||
.with(stderr_fmt)
|
||||
.with(feedback_layer)
|
||||
.with(feedback_metadata_layer)
|
||||
.with(log_db_layer)
|
||||
.with(otel_logger_layer)
|
||||
.with(otel_tracing_layer)
|
||||
.with(otel_layers)
|
||||
.try_init();
|
||||
for warning in &config_warnings {
|
||||
match &warning.details {
|
||||
@@ -816,6 +815,15 @@ pub async fn run_main_with_transport_options(
|
||||
}
|
||||
transport_accept_handles.push(remote_control_accept_handle);
|
||||
|
||||
let otel_reloader_handle = otel_reloader::spawn(
|
||||
otel,
|
||||
otel_logger_reload_handle,
|
||||
config_manager.clone(),
|
||||
Arc::clone(&auth_manager),
|
||||
default_analytics_enabled,
|
||||
transport_shutdown_token.clone(),
|
||||
);
|
||||
|
||||
let outbound_handle = tokio::spawn(async move {
|
||||
let mut outbound_connections = HashMap::<ConnectionId, OutboundConnectionState>::new();
|
||||
loop {
|
||||
@@ -1176,14 +1184,11 @@ pub async fn run_main_with_transport_options(
|
||||
let _ = outbound_handle.await;
|
||||
|
||||
transport_shutdown_token.cancel();
|
||||
let _ = otel_reloader_handle.await;
|
||||
for handle in transport_accept_handles {
|
||||
let _ = handle.await;
|
||||
}
|
||||
|
||||
if let Some(otel) = otel {
|
||||
otel.shutdown();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user