use spate_core::metrics::{Counter, Meter};
const RECORDS_DROPPED_TOTAL: &str = "records_dropped_total";
const L_REASON: &str = "reason";
const REASON_MALFORMED: &str = "malformed";
const REASON_DUPLICATE_KEY: &str = "duplicate_key";
#[derive(Clone, Debug)]
pub(crate) struct JsonDeserMetrics {
malformed: Counter,
duplicate_key: Counter,
}
impl JsonDeserMetrics {
pub(crate) fn new(meter: &Meter) -> Self {
JsonDeserMetrics {
malformed: meter.counter(
RECORDS_DROPPED_TOTAL,
&[(L_REASON, REASON_MALFORMED.into())],
),
duplicate_key: meter.counter(
RECORDS_DROPPED_TOTAL,
&[(L_REASON, REASON_DUPLICATE_KEY.into())],
),
}
}
pub(crate) fn dropped_malformed(&self) {
self.malformed.increment(1);
}
pub(crate) fn dropped_duplicate_key(&self) {
self.duplicate_key.increment(1);
}
}