use metrics::{counter, describe_counter};
pub fn describe() {
describe_counter!(
"faucet_schema_drift_total",
"Top-level columns detected as drifted, by policy mode and drift kind."
);
}
pub fn schema_drift(
pipeline: &str,
row: &str,
connector: &str,
mode: &str,
kind: &str,
count: u64,
) {
if count == 0 {
return;
}
counter!(
"faucet_schema_drift_total",
"pipeline" => pipeline.to_string(),
"row" => row.to_string(),
"connector" => connector.to_string(),
"mode" => mode.to_string(),
"kind" => kind.to_string(),
)
.increment(count);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn describe_is_callable_and_idempotent() {
describe();
describe();
}
#[test]
fn emit_does_not_panic_without_recorder() {
schema_drift("p", "r", "postgres", "evolve", "added", 2);
schema_drift("p", "r", "postgres", "ignore", "removed", 0);
}
}