vector/internal_events/
aws_ecs_metrics.rs

1use std::borrow::Cow;
2
3use metrics::counter;
4use vector_lib::{
5    internal_event::{error_stage, error_type, InternalEvent},
6    json_size::JsonSize,
7};
8
9#[derive(Debug)]
10pub struct AwsEcsMetricsEventsReceived<'a> {
11    pub byte_size: JsonSize,
12    pub count: usize,
13    pub endpoint: &'a str,
14}
15
16impl InternalEvent for AwsEcsMetricsEventsReceived<'_> {
17    fn emit(self) {
18        trace!(
19            message = "Events received.",
20            count = %self.count,
21            byte_size = %self.byte_size,
22            protocol = "http",
23            endpoint = %self.endpoint,
24        );
25        counter!(
26            "component_received_events_total",
27            "endpoint" => self.endpoint.to_string(),
28        )
29        .increment(self.count as u64);
30        counter!(
31            "component_received_event_bytes_total",
32            "endpoint" => self.endpoint.to_string(),
33        )
34        .increment(self.byte_size.get() as u64);
35    }
36}
37
38#[derive(Debug)]
39pub struct AwsEcsMetricsParseError<'a> {
40    pub error: serde_json::Error,
41    pub endpoint: &'a str,
42    pub body: Cow<'a, str>,
43}
44
45impl InternalEvent for AwsEcsMetricsParseError<'_> {
46    fn emit(self) {
47        error!(
48            message = "Parsing error.",
49            endpoint = %self.endpoint,
50            error = ?self.error,
51            stage = error_stage::PROCESSING,
52            error_type = error_type::PARSER_FAILED,
53            internal_log_rate_limit = true,
54        );
55        debug!(
56            message = %format!("Failed to parse response:\\n\\n{}\\n\\n", self.body.escape_debug()),
57            endpoint = %self.endpoint,
58            internal_log_rate_limit = true,
59        );
60        counter!("parse_errors_total").increment(1);
61        counter!(
62            "component_errors_total",
63            "stage" => error_stage::PROCESSING,
64            "error_type" => error_type::PARSER_FAILED,
65            "endpoint" => self.endpoint.to_string(),
66        )
67        .increment(1);
68    }
69}