pub const UPLOAD_TOTAL: &str = "spider_remote_cache_upload_total";
pub const UPLOAD_DURATION_MS: &str = "spider_remote_cache_upload_duration_ms";
pub const QUEUE_BYTES: &str = "spider_remote_cache_queue_bytes";
pub const DROPPED_TOTAL: &str = "spider_remote_cache_dropped_total";
pub mod outcome {
pub const OK: &str = "ok";
pub const HTTP_ERROR: &str = "http_error";
pub const SEND_ERROR: &str = "send_error";
pub const TIMEOUT: &str = "timeout";
}
pub mod reason {
pub const OVERSIZE: &str = "oversize";
pub const QUEUE_FULL: &str = "queue_full";
pub const MEMORY_BUDGET: &str = "memory_budget";
pub const CLOSED: &str = "closed";
pub const NO_WORKER: &str = "no_worker";
pub const NO_RUNTIME: &str = "no_runtime";
pub const SPOOL_BUSY: &str = "spool_busy";
pub const SPOOL_ERROR: &str = "spool_error";
pub const INFLIGHT_DUP: &str = "inflight_dup";
}
#[inline]
#[allow(unused_variables)]
pub(crate) fn upload(outcome: &'static str, elapsed_ms: f64) {
#[cfg(feature = "metrics")]
{
::metrics::counter!(UPLOAD_TOTAL, "outcome" => outcome).increment(1);
::metrics::histogram!(UPLOAD_DURATION_MS, "outcome" => outcome).record(elapsed_ms);
}
}
#[inline]
#[allow(unused_variables)]
pub(crate) fn dropped(reason: &'static str) {
#[cfg(feature = "metrics")]
::metrics::counter!(DROPPED_TOTAL, "reason" => reason).increment(1);
}
#[inline]
#[allow(unused_variables)]
pub(crate) fn queue_bytes(bytes: usize) {
#[cfg(feature = "metrics")]
::metrics::gauge!(QUEUE_BYTES).set(bytes as f64);
}