mirror of
https://github.com/openai/codex.git
synced 2026-11-07 20:30:33 +00:00
This cleans up a bunch of metric plumbing that had started to drift. The main change is making `codex-otel` the canonical home for shared metric definitions and metric tag helpers. I moved the `turn/thread` metric names that were still duplicated into the OTEL metric registry, added a shared `metrics::tags` module for common tag keys and session tag construction, and updated `SessionTelemetry` to build its metadata tags through that shared path. On the codex-core side, TTFT/TTFM now use the shared metric-name constants instead of local string definitions. I also switched the obvious remaining turn/thread metric callsites over to the shared constants, and added a small helper so TTFT/TTFM can attach an optional sanitized client.name tag from TurnContext. This should make follow-on telemetry work less ad hoc: - one canonical place for metric names - one canonical place for common metric tag keys/builders - less duplication between `codex-core` and `codex-otel`
26 lines
644 B
Rust
26 lines
644 B
Rust
mod client;
|
|
mod config;
|
|
mod error;
|
|
pub mod names;
|
|
pub(crate) mod runtime_metrics;
|
|
pub mod tags;
|
|
pub(crate) mod timer;
|
|
pub(crate) mod validation;
|
|
|
|
pub use crate::metrics::client::MetricsClient;
|
|
pub use crate::metrics::config::MetricsConfig;
|
|
pub use crate::metrics::config::MetricsExporter;
|
|
pub use crate::metrics::error::MetricsError;
|
|
pub use crate::metrics::error::Result;
|
|
use std::sync::OnceLock;
|
|
|
|
static GLOBAL_METRICS: OnceLock<MetricsClient> = OnceLock::new();
|
|
|
|
pub(crate) fn install_global(metrics: MetricsClient) {
|
|
let _ = GLOBAL_METRICS.set(metrics);
|
|
}
|
|
|
|
pub fn global() -> Option<MetricsClient> {
|
|
GLOBAL_METRICS.get().cloned()
|
|
}
|