chore: unify metric (#10220)

This commit is contained in:
jif-oai
2026-01-30 11:13:43 +01:00
committed by GitHub
parent 129787493f
commit 25ad414680

View File

@@ -11,6 +11,7 @@ use codex_otel::OtelManager;
use codex_protocol::ThreadId;
use codex_protocol::protocol::RolloutItem;
use codex_protocol::protocol::SessionSource;
use codex_state::DB_METRIC_COMPARE_ERROR;
pub use codex_state::LogEntry;
use codex_state::STATE_DB_FILENAME;
use codex_state::ThreadMetadataBuilder;
@@ -282,9 +283,10 @@ pub async fn apply_rollout_items(
pub fn record_discrepancy(stage: &str, reason: &str) {
// We access the global metric because the call sites might not have access to the broader
// OtelManager.
tracing::warn!("state db record_discrepancy: {stage}{reason}");
if let Some(metric) = codex_otel::metrics::global() {
let _ = metric.counter(
"codex.db.discrepancy",
DB_METRIC_COMPARE_ERROR,
1,
&[("stage", stage), ("reason", reason)],
);