Expose global metrics installation in codex-otel (#42603)

## What changed

Add `install_global_metrics` as the public entry point for installing an
externally managed, non-Statsig `MetricsClient` during single-threaded startup.
The returned handle retains ownership of the installed exporter so callers can
flush and shut it down.

GitOrigin-RevId: 1108a0468588046e5cc8266d2af6143f14456d82
This commit is contained in:
ostepanian
2026-09-03 19:33:56 +00:00
committed by copyberry
parent f84c9776dc
commit 7eee24ef51

View File

@@ -69,6 +69,15 @@ impl From<AuthMode> for TelemetryAuthMode {
}
}
/// Install externally managed, non-Statsig process-global metrics.
///
/// Call this once during single-threaded startup, before any instruments are
/// registered. Keep the returned handle to flush and shut down the exporter
/// owned by this installation.
pub fn install_global_metrics(metrics: MetricsClient) -> MetricsClient {
crate::metrics::install_global(metrics)
}
/// Start a metrics timer using the globally installed metrics client.
pub fn start_global_timer(name: &str, tags: &[(&str, &str)]) -> MetricsResult<Timer> {
let Some(metrics) = crate::metrics::global() else {