vector/internal_events/
statsd_sink.rs1use metrics::counter;
2use vector_lib::internal_event::{
3 ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type,
4};
5
6use crate::event::metric::{MetricKind, MetricValue};
7
8#[derive(Debug)]
9pub struct StatsdInvalidMetricError<'a> {
10 pub value: &'a MetricValue,
11 pub kind: MetricKind,
12}
13
14impl InternalEvent for StatsdInvalidMetricError<'_> {
15 fn emit(self) {
16 let reason = "Invalid metric type received.";
17 error!(
18 message = reason,
19 error_code = "invalid_metric",
20 error_type = error_type::ENCODER_FAILED,
21 stage = error_stage::PROCESSING,
22 value = ?self.value,
23 kind = ?self.kind,
24 internal_log_rate_limit = true,
25 );
26 counter!(
27 "component_errors_total",
28 "error_code" => "invalid_metric",
29 "error_type" => error_type::ENCODER_FAILED,
30 "stage" => error_stage::PROCESSING,
31 )
32 .increment(1);
33
34 emit!(ComponentEventsDropped::<UNINTENTIONAL> { reason, count: 1 });
35 }
36}