vector/internal_events/
metric_to_log.rs1use metrics::counter;
2use serde_json::Error;
3use vector_lib::internal_event::InternalEvent;
4use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL};
5
6#[derive(Debug)]
7pub struct MetricToLogSerializeError {
8 pub error: Error,
9}
10
11impl InternalEvent for MetricToLogSerializeError {
12 fn emit(self) {
13 let reason = "Metric failed to serialize as JSON.";
14 error!(
15 message = reason,
16 error = ?self.error,
17 error_type = error_type::ENCODER_FAILED,
18 stage = error_stage::PROCESSING,
19 internal_log_rate_limit = true
20 );
21 counter!(
22 "component_errors_total",
23 "error_type" => error_type::ENCODER_FAILED,
24 "stage" => error_stage::PROCESSING,
25 )
26 .increment(1);
27
28 emit!(ComponentEventsDropped::<UNINTENTIONAL> { count: 1, reason })
29 }
30}