vector/internal_events/
apache_metrics.rs1use metrics::counter;
2use vector_lib::{
3 NamedInternalEvent,
4 internal_event::{InternalEvent, error_stage, error_type},
5 json_size::JsonSize,
6};
7
8use crate::sources::apache_metrics;
9
10#[derive(Debug, NamedInternalEvent)]
11pub struct ApacheMetricsEventsReceived<'a> {
12 pub byte_size: JsonSize,
13 pub count: usize,
14 pub endpoint: &'a str,
15}
16
17impl InternalEvent for ApacheMetricsEventsReceived<'_> {
18 fn emit(self) {
20 trace!(message = "Events received.", count = %self.count, byte_size = %self.byte_size, endpoint = %self.endpoint);
21 counter!(
22 "component_received_events_total",
23 "endpoint" => self.endpoint.to_owned(),
24 )
25 .increment(self.count as u64);
26 counter!(
27 "component_received_event_bytes_total",
28 "endpoint" => self.endpoint.to_owned(),
29 )
30 .increment(self.byte_size.get() as u64);
31 }
32}
33
34#[derive(Debug, NamedInternalEvent)]
35pub struct ApacheMetricsParseError<'a> {
36 pub error: apache_metrics::ParseError,
37 pub endpoint: &'a str,
38}
39
40impl InternalEvent for ApacheMetricsParseError<'_> {
41 fn emit(self) {
42 error!(
43 message = "Parsing error.",
44 error = ?self.error,
45 stage = error_stage::PROCESSING,
46 error_type = error_type::PARSER_FAILED,
47 endpoint = %self.endpoint,
48 );
49 counter!(
50 "component_errors_total",
51 "stage" => error_stage::PROCESSING,
52 "error_type" => error_type::PARSER_FAILED,
53 "endpoint" => self.endpoint.to_owned(),
54 )
55 .increment(1);
56 }
57}