mirror of
https://github.com/openai/codex.git
synced 2026-11-25 15:24:26 +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
@@ -16,7 +16,9 @@ pub use crate::metrics::error::MetricsError;
|
||||
pub use crate::metrics::error::Result;
|
||||
pub use crate::metrics::process::record_process_start_once;
|
||||
pub use names::*;
|
||||
use std::sync::Arc;
|
||||
use std::sync::OnceLock;
|
||||
use std::sync::RwLock;
|
||||
pub use tags::ORIGINATOR_TAG;
|
||||
pub use tags::SessionMetricTagValues;
|
||||
pub use tags::bounded_originator_tag_value;
|
||||
@@ -24,8 +26,17 @@ pub use tags::bounded_originator_tag_value;
|
||||
static GLOBAL_METRICS: OnceLock<MetricsClient> = OnceLock::new();
|
||||
static GLOBAL_STATSIG_METRICS_SETTINGS: OnceLock<StatsigMetricsSettings> = OnceLock::new();
|
||||
|
||||
pub(crate) fn install_global(metrics: MetricsClient) {
|
||||
let _ = GLOBAL_METRICS.set(metrics);
|
||||
pub(crate) fn install_global(mut metrics: MetricsClient) -> MetricsClient {
|
||||
let active = GLOBAL_METRICS
|
||||
.get()
|
||||
.and_then(|current| current.active.clone())
|
||||
.unwrap_or_else(|| Arc::new(RwLock::new(Arc::clone(&metrics.inner))));
|
||||
*active
|
||||
.write()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner) = Arc::clone(&metrics.inner);
|
||||
metrics.active = Some(active);
|
||||
let _ = GLOBAL_METRICS.set(metrics.clone());
|
||||
metrics
|
||||
}
|
||||
|
||||
pub fn global() -> Option<MetricsClient> {
|
||||
|
||||
Reference in new issue
Block a user