#[inline]
pub fn record_commit(duration: std::time::Duration) {
#[cfg(feature = "observe")]
{
metrics::counter!("azoth.transaction.commits_total").increment(1);
metrics::histogram!("azoth.transaction.commit_duration_seconds")
.record(duration.as_secs_f64());
}
#[cfg(not(feature = "observe"))]
{
let _ = duration;
}
}
#[inline]
pub fn record_preflight(duration: std::time::Duration, success: bool) {
#[cfg(feature = "observe")]
{
let outcome = if success { "ok" } else { "fail" };
metrics::counter!("azoth.preflight.total", "outcome" => outcome).increment(1);
metrics::histogram!("azoth.preflight.duration_seconds").record(duration.as_secs_f64());
}
#[cfg(not(feature = "observe"))]
{
let _ = (duration, success);
}
}
#[inline]
pub fn record_cache_lookup(hit: bool) {
#[cfg(feature = "observe")]
{
let result = if hit { "hit" } else { "miss" };
metrics::counter!("azoth.preflight_cache.lookups_total", "result" => result).increment(1);
}
#[cfg(not(feature = "observe"))]
{
let _ = hit;
}
}
#[inline]
pub fn set_cache_size(size: usize) {
#[cfg(feature = "observe")]
{
metrics::gauge!("azoth.preflight_cache.size").set(size as f64);
}
#[cfg(not(feature = "observe"))]
{
let _ = size;
}
}
#[inline]
pub fn record_projector_run(duration: std::time::Duration, events_processed: u64) {
#[cfg(feature = "observe")]
{
metrics::counter!("azoth.projector.runs_total").increment(1);
metrics::histogram!("azoth.projector.run_duration_seconds").record(duration.as_secs_f64());
metrics::counter!("azoth.projector.events_processed_total").increment(events_processed);
}
#[cfg(not(feature = "observe"))]
{
let _ = (duration, events_processed);
}
}
#[inline]
pub fn record_lock_wait(duration: std::time::Duration) {
#[cfg(feature = "observe")]
{
metrics::histogram!("azoth.lock.wait_duration_seconds").record(duration.as_secs_f64());
}
#[cfg(not(feature = "observe"))]
{
let _ = duration;
}
}
#[inline]
pub fn record_backup(duration: std::time::Duration, success: bool) {
#[cfg(feature = "observe")]
{
let outcome = if success { "ok" } else { "fail" };
metrics::counter!("azoth.backup.total", "outcome" => outcome).increment(1);
metrics::histogram!("azoth.backup.duration_seconds").record(duration.as_secs_f64());
}
#[cfg(not(feature = "observe"))]
{
let _ = (duration, success);
}
}