use metrics::{counter, describe_counter};
pub fn describe() {
describe_counter!(
"faucet_cleanup_deleted_total",
"Destination rows deleted by scoped cleanup because they were not written by the run."
);
describe_counter!(
"faucet_cleanup_runs_total",
"Scoped-cleanup passes, by outcome (applied / skipped_cancelled / refused_overflow)."
);
}
pub fn cleanup_deleted(pipeline: &str, row: &str, connector: &str, deleted: u64) {
counter!(
"faucet_cleanup_deleted_total",
"pipeline" => pipeline.to_string(),
"row" => row.to_string(),
"connector" => connector.to_string(),
)
.increment(deleted);
}
pub fn cleanup_run(pipeline: &str, row: &str, outcome: &'static str) {
counter!(
"faucet_cleanup_runs_total",
"pipeline" => pipeline.to_string(),
"row" => row.to_string(),
"outcome" => outcome,
)
.increment(1);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn describe_is_callable_and_idempotent() {
describe();
describe();
}
#[test]
fn emitters_are_callable_without_a_recorder() {
cleanup_deleted("p", "r", "postgres", 0);
cleanup_deleted("p", "r", "postgres", 7);
cleanup_run("p", "r", "applied");
cleanup_run("p", "r", "refused_overflow");
}
}