mirror of
https://github.com/openai/codex.git
synced 2026-11-14 21:40:39 +00:00
## What changed - Add `StorageTelemetry` to record operation counts, durations, secure-store outcomes, and file fallback reasons using bounded labels. Emit fallback warnings without credential payloads or error text. - Add task-local client attribution with explicit propagation across task boundaries. - Preserve typed keyring error causes through `std::io::Error` and the local secrets backend, classifying supported native failures without parsing error messages. - Remove service names, account names, value lengths, and error text from keyring trace logs. ## Testing Add tests for buffered metric emission, fallback outcomes, exclusion of sensitive error contents, client attribution isolation, and typed native error classification. GitOrigin-RevId: 18e7201566a3b09061a6014fd6bd90eae96e3fc2
46 lines
1.2 KiB
Rust
46 lines
1.2 KiB
Rust
//! Bounded attribution for auth-storage observations, scoped to one task.
|
|
//! Spawned tasks must explicitly carry this context across the task boundary.
|
|
|
|
use std::future::Future;
|
|
|
|
tokio::task_local! {
|
|
static CURRENT: AuthStorageOriginator;
|
|
}
|
|
|
|
/// A bounded client identity used only by credential-storage telemetry.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub struct AuthStorageOriginator(&'static str);
|
|
|
|
impl AuthStorageOriginator {
|
|
pub fn from_client_name(name: &str) -> Self {
|
|
let name = match name {
|
|
"Codex Desktop" => "codex_desktop",
|
|
_ => name,
|
|
};
|
|
Self(crate::bounded_originator_tag_value(name))
|
|
}
|
|
|
|
/// Unattributed work must not borrow another connection's identity.
|
|
pub fn current() -> Self {
|
|
CURRENT
|
|
.try_with(|originator| *originator)
|
|
.unwrap_or(Self("none"))
|
|
}
|
|
|
|
pub fn as_str(self) -> &'static str {
|
|
self.0
|
|
}
|
|
|
|
pub async fn scope<F: Future>(self, future: F) -> F::Output {
|
|
CURRENT.scope(self, future).await
|
|
}
|
|
|
|
pub fn sync_scope<R>(self, operation: impl FnOnce() -> R) -> R {
|
|
CURRENT.sync_scope(self, operation)
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "originator_tests.rs"]
|
|
mod tests;
|