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 internal_log_rate_limit = true,
22 );
23 counter!(
24 "component_errors_total",
25 "error_code" => self.error_code,
26 "error_type" => error_type::ENCODER_FAILED,
27 "stage" => error_stage::PROCESSING,
28 )
29 .increment(1);
30
31 if self.dropped_events > 0 {
32 emit!(ComponentEventsDropped::<UNINTENTIONAL> {
33 count: self.dropped_events,
34 reason: self.reason,
35 });
36 }
37 }
38}