Files
crank/crates/crank-observability/src/incidents.rs
T
bsodfather 0e8f1ca03a
CI / Rust Checks (push) Failing after 4m28s
CI / UI Checks (push) Has been skipped
CI / Frontend E2E (push) Has been skipped
CI / Community Image Smoke (push) Has been skipped
CI / Deploy (push) Has been skipped
наблюдаемость: завершить базовый контур Community
Добавить структурированные журналы, метрики, трассировку и безопасный канал критических ошибок. Усилить границы рантайма, тесты, проверку зависимостей и сценарии развёртывания.
2026-07-31 01:01:14 +03:00

37 lines
1.1 KiB
Rust

use std::sync::atomic::{AtomicU64, Ordering};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum OperationalIncident {
InvocationHistoryLost,
}
static INVOCATION_HISTORY_LOST_TOTAL: AtomicU64 = AtomicU64::new(0);
pub fn record_operational_incident(incident: OperationalIncident) {
let counter = counter(incident);
let _ = counter.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |value| {
value.checked_add(1)
});
match incident {
OperationalIncident::InvocationHistoryLost => {
metrics::counter!("crank_invocation_history_lost_total").increment(1);
metrics::counter!(
"crank_telemetry_export_failures_total",
"signal_type" => "invocation_history",
"exporter" => "postgres"
)
.increment(1);
}
}
}
pub fn operational_incident_total(incident: OperationalIncident) -> u64 {
counter(incident).load(Ordering::Relaxed)
}
fn counter(incident: OperationalIncident) -> &'static AtomicU64 {
match incident {
OperationalIncident::InvocationHistoryLost => &INVOCATION_HISTORY_LOST_TOTAL,
}
}