vector/internal_events/
datadog_metrics.rs1use metrics::counter;
2use vector_lib::internal_event::{
3 ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type,
4};
5
6#[derive(Debug)]
7pub struct DatadogMetricsEncodingError<'a> {
8 pub reason: &'a str,
9 pub error_code: &'static str,
10 pub dropped_events: usize,
11}
12
13impl InternalEvent for DatadogMetricsEncodingError<'_> {
14 fn emit(self) {
15 error!(
16 message = self.reason,
17 error_code = self.error_code,
18 error_type = error_type::ENCODER_FAILED,
19 intentional = "false",
20 stage = error_stage::PROCESSING,
21 );
22 counter!(
23 "component_errors_total",
24 "error_code" => self.error_code,
25 "error_type" => error_type::ENCODER_FAILED,
26 "stage" => error_stage::PROCESSING,
27 )
28 .increment(1);
29
30 if self.dropped_events > 0 {
31 emit!(ComponentEventsDropped::<UNINTENTIONAL> {
32 count: self.dropped_events,
33 reason: self.reason,
34 });
35 }
36 }
37}