mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
## Summary - add SQLite init, backfill-gate, and fallback telemetry without introducing a cross-cutting state-db access wrapper - install one process-scoped telemetry sink after OTEL startup and let low-level state/rollout paths emit through it directly - add process-start metrics for the process owners that initialize SQLite --------- Co-authored-by: Owen Lin <owen@openai.com>
28 lines
809 B
Rust
28 lines
809 B
Rust
use std::sync::atomic::AtomicBool;
|
|
use std::sync::atomic::Ordering;
|
|
|
|
use super::client::MetricsClient;
|
|
use super::error::Result;
|
|
use super::names::PROCESS_START_METRIC;
|
|
use super::tags::ORIGINATOR_TAG;
|
|
use super::tags::bounded_originator_tag_value;
|
|
|
|
static PROCESS_START_RECORDED: AtomicBool = AtomicBool::new(false);
|
|
|
|
/// Record the process start counter at most once for this process.
|
|
pub fn record_process_start_once(metrics: &MetricsClient, originator: &str) -> Result<bool> {
|
|
if PROCESS_START_RECORDED
|
|
.compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed)
|
|
.is_err()
|
|
{
|
|
return Ok(false);
|
|
}
|
|
|
|
metrics.counter(
|
|
PROCESS_START_METRIC,
|
|
/*inc*/ 1,
|
|
&[(ORIGINATOR_TAG, bounded_originator_tag_value(originator))],
|
|
)?;
|
|
Ok(true)
|
|
}
|