vector/internal_events/
sematext_metrics.rs1use metrics::counter;
2use vector_lib::internal_event::InternalEvent;
3use vector_lib::internal_event::{error_stage, error_type, ComponentEventsDropped, UNINTENTIONAL};
4
5use crate::event::metric::Metric;
6
7#[derive(Debug)]
8pub struct SematextMetricsInvalidMetricError<'a> {
9 pub metric: &'a Metric,
10}
11
12impl InternalEvent for SematextMetricsInvalidMetricError<'_> {
13 fn emit(self) {
14 let reason = "Invalid metric received.";
15 error!(
16 message = reason,
17 error_code = "invalid_metric",
18 error_type = error_type::ENCODER_FAILED,
19 stage = error_stage::PROCESSING,
20 value = ?self.metric.value(),
21 kind = ?self.metric.kind(),
22 internal_log_rate_limit = true,
23 );
24 counter!(
25 "component_errors_total",
26 "error_code" => "invalid_metric",
27 "error_type" => error_type::ENCODER_FAILED,
28 "stage" => error_stage::PROCESSING,
29 )
30 .increment(1);
31
32 emit!(ComponentEventsDropped::<UNINTENTIONAL> { count: 1, reason });
33 }
34}
35
36#[derive(Debug)]
37pub struct SematextMetricsEncodeEventError<E> {
38 pub error: E,
39}
40
41impl<E: std::fmt::Display> InternalEvent for SematextMetricsEncodeEventError<E> {
42 fn emit(self) {
43 let reason = "Failed to encode event.";
44 error!(
45 message = reason,
46 error = %self.error,
47 error_type = error_type::ENCODER_FAILED,
48 stage = error_stage::PROCESSING,
49 internal_log_rate_limit = true,
50 );
51 counter!(
52 "component_errors_total",
53 "error_type" => error_type::ENCODER_FAILED,
54 "stage" => error_stage::PROCESSING,
55 )
56 .increment(1);
57
58 emit!(ComponentEventsDropped::<UNINTENTIONAL> { count: 1, reason });
59 }
60}