use metrics::counter;
use vector_lib::internal_event::InternalEvent;
use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL};
#[derive(Debug)]
pub struct InfluxdbEncodingError {
pub error_message: &'static str,
pub count: usize,
}
impl InternalEvent for InfluxdbEncodingError {
fn emit(self) {
let reason = "Failed to encode event.";
error!(
message = reason,
error = %self.error_message,
error_type = error_type::ENCODER_FAILED,
stage = error_stage::PROCESSING,
internal_log_rate_limit = true,
);
counter!(
"component_errors_total",
"error_type" => error_type::ENCODER_FAILED,
"stage" => error_stage::PROCESSING,
)
.increment(1);
emit!(ComponentEventsDropped::<UNINTENTIONAL> {
count: self.count,
reason
});
}
}